pub struct AuthClient { /* private fields */ }Expand description
Firebase Authentication client.
A single concrete type serves both live and emulator use: mode is a
runtime field (ClientMode), not a type parameter, so every method
below has exactly one signature regardless of environment. Build one with
AuthClientBuilder.
Implementations§
Source§impl AuthClient
impl AuthClient
Sourcepub fn builder(project_id: impl Into<String>) -> AuthClientBuilder
pub fn builder(project_id: impl Into<String>) -> AuthClientBuilder
Starts building a new client for the given Firebase project.
Sourcepub fn project_id(&self) -> &ProjectId
pub fn project_id(&self) -> &ProjectId
Returns the Firebase project id this client is configured for.
Sourcepub async fn verify_id_token(
&self,
token: &str,
) -> Result<IdTokenClaims, AuthError>
pub async fn verify_id_token( &self, token: &str, ) -> Result<IdTokenClaims, AuthError>
Verifies a Firebase ID token, returning its claims.
Sourcepub fn create_custom_token(
&self,
uid: &str,
claims: Option<Map<String, Value>>,
) -> Result<String, AuthError>
pub fn create_custom_token( &self, uid: &str, claims: Option<Map<String, Value>>, ) -> Result<String, AuthError>
Creates a Firebase custom token for the given uid.
Requires the client to have been built with an explicit service account key; Application Default Credentials do not expose a private key and cannot sign custom tokens.
Exchanges a verified ID token for a session cookie valid for
valid_duration (Firebase allows up to 14 days).
Verifies a Firebase session cookie, returning its claims.
Verified against a different certificate endpoint and issuer than
Self::verify_id_token — see crate::auth::session_cookie::verify
for why the two aren’t interchangeable.
Sourcepub async fn get_user(&self, uid: &str) -> Result<UserRecord, AuthError>
pub async fn get_user(&self, uid: &str) -> Result<UserRecord, AuthError>
Fetches a user by uid.
Sourcepub async fn get_user_by_email(
&self,
email: &str,
) -> Result<UserRecord, AuthError>
pub async fn get_user_by_email( &self, email: &str, ) -> Result<UserRecord, AuthError>
Fetches a user by email address.
Sourcepub async fn create_user(
&self,
request: CreateUserRequest,
) -> Result<UserRecord, AuthError>
pub async fn create_user( &self, request: CreateUserRequest, ) -> Result<UserRecord, AuthError>
Creates a new user.
Sourcepub async fn update_user(
&self,
uid: &str,
request: UpdateUserRequest,
) -> Result<UserRecord, AuthError>
pub async fn update_user( &self, uid: &str, request: UpdateUserRequest, ) -> Result<UserRecord, AuthError>
Updates an existing user.