pub struct FirebaseAuth {
pub id_token: String,
pub refresh_token: String,
pub local_id: String,
/* private fields */
}Expand description
Holds Firebase auth tokens and handles transparent refresh.
Obtain an instance via FirebaseAuth::login. The short-lived id_token
is refreshed automatically when it is within 5 minutes of
expiry; only the long-lived refresh_token needs to be persisted across
restarts.
Fields§
§id_token: StringCurrent Firebase ID token (valid for ~1 hour).
refresh_token: StringLong-lived refresh token used to obtain new ID tokens.
local_id: StringFirebase user ID (localId) returned at login.
Implementations§
Source§impl FirebaseAuth
impl FirebaseAuth
Sourcepub async fn login(client: Client, email: &str, password: &str) -> Result<Self>
pub async fn login(client: Client, email: &str, password: &str) -> Result<Self>
Authenticate with email and password, returning a FirebaseAuth with
fresh tokens.
Uses the Firebase Identity Toolkit verifyPassword endpoint.
Sourcepub async fn refresh(&mut self) -> Result<()>
pub async fn refresh(&mut self) -> Result<()>
Exchange the refresh token for a new id token.
Called automatically by Self::ensure_valid_token; you rarely need
to call this directly.
Sourcepub async fn ensure_valid_token(&mut self) -> Result<String>
pub async fn ensure_valid_token(&mut self) -> Result<String>
Return the current id token, refreshing it first if it is about to expire.
This is the primary method used by crate::RointeClient before every
Firebase request.
Trait Implementations§
Source§impl Clone for FirebaseAuth
impl Clone for FirebaseAuth
Source§fn clone(&self) -> FirebaseAuth
fn clone(&self) -> FirebaseAuth
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more