pub struct Auth { /* private fields */ }Implementations§
Source§impl Auth
impl Auth
Sourcepub fn builder(app: FirebaseApp) -> AuthBuilder
pub fn builder(app: FirebaseApp) -> AuthBuilder
Creates a builder for configuring an Auth instance before construction.
Sourcepub fn new(app: FirebaseApp) -> AuthResult<Self>
pub fn new(app: FirebaseApp) -> AuthResult<Self>
Constructs an Auth instance using in-memory persistence.
Sourcepub fn new_with_persistence(
app: FirebaseApp,
persistence: Arc<dyn AuthPersistence + Send + Sync>,
) -> AuthResult<Self>
pub fn new_with_persistence( app: FirebaseApp, persistence: Arc<dyn AuthPersistence + Send + Sync>, ) -> AuthResult<Self>
Constructs an Auth instance with a caller-provided persistence backend.
Sourcepub fn initialize(self: &Arc<Self>) -> AuthResult<()>
pub fn initialize(self: &Arc<Self>) -> AuthResult<()>
Finishes initialization by restoring persisted state and wiring listeners.
Sourcepub fn app(&self) -> &FirebaseApp
pub fn app(&self) -> &FirebaseApp
Returns the FirebaseApp associated with this Auth instance.
Sourcepub fn current_user(&self) -> Option<Arc<User>>
pub fn current_user(&self) -> Option<Arc<User>>
Returns the currently signed-in user, if any.
Sourcepub fn email_auth_provider(&self) -> EmailAuthProvider
pub fn email_auth_provider(&self) -> EmailAuthProvider
Returns the email/password auth provider helper.
Sourcepub fn sign_in_with_email_and_password(
&self,
email: &str,
password: &str,
) -> AuthResult<UserCredential>
pub fn sign_in_with_email_and_password( &self, email: &str, password: &str, ) -> AuthResult<UserCredential>
Signs a user in using the email/password REST endpoint.
Sourcepub fn create_user_with_email_and_password(
&self,
email: &str,
password: &str,
) -> AuthResult<UserCredential>
pub fn create_user_with_email_and_password( &self, email: &str, password: &str, ) -> AuthResult<UserCredential>
Creates a new user using email/password credentials.
Sourcepub fn on_auth_state_changed(
&self,
observer: PartialObserver<Arc<User>>,
) -> impl FnOnce() + Send + 'static
pub fn on_auth_state_changed( &self, observer: PartialObserver<Arc<User>>, ) -> impl FnOnce() + Send + 'static
Registers an observer that is invoked whenever auth state changes.
Sourcepub fn get_token(&self, force_refresh: bool) -> AuthResult<Option<String>>
pub fn get_token(&self, force_refresh: bool) -> AuthResult<Option<String>>
Returns the current user’s ID token, refreshing when requested.
Sourcepub fn token_provider(self: &Arc<Self>) -> TokenProviderArc
pub fn token_provider(self: &Arc<Self>) -> TokenProviderArc
Exposes this auth instance as a Firestore token provider.
Sourcepub fn set_oauth_request_uri(&self, value: impl Into<String>)
pub fn set_oauth_request_uri(&self, value: impl Into<String>)
Overrides the default OAuth request URI used during flows.
Sourcepub fn oauth_request_uri(&self) -> String
pub fn oauth_request_uri(&self) -> String
Returns the OAuth request URI for popup/redirect flows.
Sourcepub fn set_identity_toolkit_endpoint(&self, endpoint: impl Into<String>)
pub fn set_identity_toolkit_endpoint(&self, endpoint: impl Into<String>)
Updates the Identity Toolkit REST endpoint.
Sourcepub fn identity_toolkit_endpoint(&self) -> String
pub fn identity_toolkit_endpoint(&self) -> String
Returns the Identity Toolkit REST endpoint in use.
Sourcepub fn set_secure_token_endpoint(&self, endpoint: impl Into<String>)
pub fn set_secure_token_endpoint(&self, endpoint: impl Into<String>)
Sets the Secure Token endpoint used for refresh operations.
Sourcepub fn set_popup_handler(&self, handler: Arc<dyn OAuthPopupHandler>)
pub fn set_popup_handler(&self, handler: Arc<dyn OAuthPopupHandler>)
Installs an OAuth popup handler implementation.
Sourcepub fn clear_popup_handler(&self)
pub fn clear_popup_handler(&self)
Clears any installed popup handler.
Sourcepub fn popup_handler(&self) -> Option<Arc<dyn OAuthPopupHandler>>
pub fn popup_handler(&self) -> Option<Arc<dyn OAuthPopupHandler>>
Retrieves the currently configured popup handler.
Sourcepub fn set_redirect_handler(&self, handler: Arc<dyn OAuthRedirectHandler>)
pub fn set_redirect_handler(&self, handler: Arc<dyn OAuthRedirectHandler>)
Installs an OAuth redirect handler implementation.
Sourcepub fn clear_redirect_handler(&self)
pub fn clear_redirect_handler(&self)
Clears any installed redirect handler.
Sourcepub fn redirect_handler(&self) -> Option<Arc<dyn OAuthRedirectHandler>>
pub fn redirect_handler(&self) -> Option<Arc<dyn OAuthRedirectHandler>>
Retrieves the currently configured redirect handler.
Sourcepub fn set_redirect_persistence(
&self,
persistence: Arc<dyn RedirectPersistence>,
)
pub fn set_redirect_persistence( &self, persistence: Arc<dyn RedirectPersistence>, )
Replaces the persistence mechanism used for redirect state.
Sourcepub fn sign_in_with_oauth_credential(
&self,
credential: AuthCredential,
) -> AuthResult<UserCredential>
pub fn sign_in_with_oauth_credential( &self, credential: AuthCredential, ) -> AuthResult<UserCredential>
Signs in using an OAuth credential produced by popup/redirect flows.
Sourcepub fn send_password_reset_email(&self, email: &str) -> AuthResult<()>
pub fn send_password_reset_email(&self, email: &str) -> AuthResult<()>
Sends a password reset email to the specified address.
Sourcepub fn confirm_password_reset(
&self,
oob_code: &str,
new_password: &str,
) -> AuthResult<()>
pub fn confirm_password_reset( &self, oob_code: &str, new_password: &str, ) -> AuthResult<()>
Confirms a password reset OOB code and applies the new password.
Sourcepub fn send_email_verification(&self) -> AuthResult<()>
pub fn send_email_verification(&self) -> AuthResult<()>
Sends an email verification message to the currently signed-in user.
Sourcepub fn update_profile(
&self,
display_name: Option<&str>,
photo_url: Option<&str>,
) -> AuthResult<Arc<User>>
pub fn update_profile( &self, display_name: Option<&str>, photo_url: Option<&str>, ) -> AuthResult<Arc<User>>
Updates the current user’s display name and photo URL.
Sourcepub fn update_email(&self, email: &str) -> AuthResult<Arc<User>>
pub fn update_email(&self, email: &str) -> AuthResult<Arc<User>>
Updates the current user’s email address.
Sourcepub fn update_password(&self, password: &str) -> AuthResult<Arc<User>>
pub fn update_password(&self, password: &str) -> AuthResult<Arc<User>>
Updates the current user’s password.
Sourcepub fn delete_user(&self) -> AuthResult<()>
pub fn delete_user(&self) -> AuthResult<()>
Deletes the current user from Firebase Auth.
Sourcepub fn unlink_providers(&self, provider_ids: &[&str]) -> AuthResult<Arc<User>>
pub fn unlink_providers(&self, provider_ids: &[&str]) -> AuthResult<Arc<User>>
Unlinks the specified providers from the current user.
Sourcepub fn get_account_info(&self) -> AuthResult<GetAccountInfoResponse>
pub fn get_account_info(&self) -> AuthResult<GetAccountInfoResponse>
Fetches the latest account info for the current user.
Sourcepub fn link_with_oauth_credential(
&self,
credential: AuthCredential,
) -> AuthResult<UserCredential>
pub fn link_with_oauth_credential( &self, credential: AuthCredential, ) -> AuthResult<UserCredential>
Links an OAuth credential with the currently signed-in user.
Sourcepub fn reauthenticate_with_password(
&self,
email: &str,
password: &str,
) -> AuthResult<Arc<User>>
pub fn reauthenticate_with_password( &self, email: &str, password: &str, ) -> AuthResult<Arc<User>>
Reauthenticates the current user with email and password.
Sourcepub fn reauthenticate_with_oauth_credential(
&self,
credential: AuthCredential,
) -> AuthResult<Arc<User>>
pub fn reauthenticate_with_oauth_credential( &self, credential: AuthCredential, ) -> AuthResult<Arc<User>>
Reauthenticates the current user with an OAuth credential.