Ir a la consola


#include <auth.h>

Firebase authentication object.


firebase::auth::Auth is the gateway to the Firebase authentication API. With it, you can reference firebase::auth::User objects to manage user accounts and credentials.

Each firebase::App has up to one firebase::auth::Auth class. You acquire the firebase::auth::Auth class through the static function firebase::auth::Auth::GetAuth.

For example:

// Get the Auth class for your App.
firebase::auth::Auth* auth = firebase::auth::Auth::GetAuth(app);

// Request anonymous sign-in and wait until asynchronous call completes.
firebase::Future sign_in_future =
while (sign_in_future.status() == firebase::kFutureStatusPending) {
  printf("Signing in...\n");

// Print sign in results.
const firebase::auth::AuthError error =
if (error != firebase::auth::kAuthErrorNone) {
  printf("Sign in failed with error `%s`\n",
} else {
  firebase::auth::User* user = *sign_in_future.result();
  printf("Signed in as %s user.\n",
         user->Anonymous() ? "an anonymous" : "a non-anonymous");

Constructors and Destructors


Public functions

AddAuthStateListener(AuthStateListener *listener)
Registers a listener to changes in the authentication state.
AddIdTokenListener(IdTokenListener *listener)
Registers a listener to changes in the ID token state.
CreateUserWithEmailAndPassword(const char *email, const char *password)
Future< User * >
Creates, and on success, logs in a user with the given email address and password.
CreateUserWithEmailAndPasswordLastResult() const
Future< User * >
Get results of the most recent call to CreateUserWithEmailAndPassword.
FetchProvidersForEmail(const char *email)
Asynchronously requests the IDPs (identity providers) that can be used for the given email address.
FetchProvidersForEmailLastResult() const
Get results of the most recent call to FetchProvidersForEmail.
RemoveAuthStateListener(AuthStateListener *listener)
Unregisters a listener of authentication changes.
RemoveIdTokenListener(IdTokenListener *listener)
Unregisters a listener of ID token changes.
SendPasswordResetEmail(const char *email)
Future< void >
Initiates a password reset for the given email address.
SendPasswordResetEmailLastResult() const
Future< void >
Get results of the most recent call to SendPasswordResetEmail.
SignInAndRetrieveDataWithCredential(const Credential & credential)
Asynchronously logs into Firebase with the given credentials.
SignInAndRetrieveDataWithCredentialLastResult() const
Get results of the most recent call to SignInAndRetrieveDataWithCredential.
Future< User * >
Asynchronously creates and becomes an anonymous user.
SignInAnonymouslyLastResult() const
Future< User * >
Get results of the most recent call to SignInAnonymously.
SignInWithCredential(const Credential & credential)
Future< User * >
Convenience method for SignInAndRetrieveDataWithCredential that doesn't return additional identity provider data.