[−][src]Struct firestore_db_and_auth::sessions::user::Session
An impersonated session. Firestore rules will restrict your access.
Fields
user_id: String
The firebase auth user id
refresh_token: Option<String>
The refresh token, if any. Such a token allows you to generate new, valid access tokens. This library will handle this for you, if for example your current access token expired.
api_key: String
The firebase projects API key, as defined in the credentials object
client: Client
The http client. Replace or modify the client if you have special demands like proxy support
Methods
impl Session
[src]
pub fn new(
credentials: &Credentials,
user_id: Option<&str>,
firebase_tokenid: Option<&str>,
refresh_token: Option<&str>
) -> Result<Session, FirebaseError>
[src]
credentials: &Credentials,
user_id: Option<&str>,
firebase_tokenid: Option<&str>,
refresh_token: Option<&str>
) -> Result<Session, FirebaseError>
Create an impersonated session
If the optionally provided access token is still valid, it will be used. If the access token is not valid anymore, but the given refresh token is, it will be used to retrieve a new access token.
If neither refresh token nor access token work are provided or valid, the service account credentials will be used to generate a new impersonated refresh and access token for the given user.
If none of the parameters are given, the function will error out.
See:
- https://firebase.google.com/docs/reference/rest/auth#section-refresh-token
- https://firebase.google.com/docs/auth/admin/create-custom-tokens#create_custom_tokens_using_a_third-party_jwt_library
pub fn by_refresh_token(
credentials: &Credentials,
refresh_token: &str
) -> Result<Session, FirebaseError>
[src]
credentials: &Credentials,
refresh_token: &str
) -> Result<Session, FirebaseError>
Create a new firestore user session via a valid refresh_token
Arguments:
credentials
The credentialsrefresh_token
A refresh token.
pub fn by_user_id(
credentials: &Credentials,
user_id: &str,
with_refresh_token: bool
) -> Result<Session, FirebaseError>
[src]
credentials: &Credentials,
user_id: &str,
with_refresh_token: bool
) -> Result<Session, FirebaseError>
Create a new firestore user session with a fresh access token.
Arguments:
credentials
The credentialsuser_id
The firebase Authentication user id. Usually a string of about 30 characters like "Io2cPph06rUWM3ABcIHguR3CIw6v1".with_refresh_token
A refresh token is returned as well. This should be persisted somewhere for later reuse. Google generates only a few dozens of refresh tokens before it starts to invalidate already generated ones. For short lived, immutable, non-persisting services you do not want a refresh token.
pub fn by_access_token(
credentials: &Credentials,
firebase_tokenid: &str
) -> Result<Session, FirebaseError>
[src]
credentials: &Credentials,
firebase_tokenid: &str
) -> Result<Session, FirebaseError>
Trait Implementations
impl FirebaseAuthBearer for Session
[src]
fn project_id(&self) -> &str
[src]
fn access_token(&self) -> String
[src]
Returns the current access token. This method will automatically refresh your access token, if it has expired.
If the refresh failed, this will
fn access_token_unchecked(&self) -> String
[src]
fn client(&self) -> &Client
[src]
Auto Trait Implementations
impl Unpin for Session
impl !Sync for Session
impl Send for Session
impl !UnwindSafe for Session
impl !RefUnwindSafe for Session
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,