firebase::auth::User

#include <user.h>

Firebase user account object.

Summary

This class allows you to manipulate the profile of a user, link to and unlink from authentication providers, and refresh authentication tokens.

Inheritance

Inherits from: firebase::auth::UserInfoInterface

Public functions

Anonymous() const
FIREBASE_DEPRECATED bool
Deprecated. Renamed to is_anonymous().
Returns true if user signed in anonymously.
Delete()
Future< void >
Deletes the user account.
DeleteLastResult() const
Future< void >
Get results of the most recent call to Delete.
DisplayName() const
FIREBASE_DEPRECATED std::string
Deprecated. Renamed to display_name().
Gets the display name associated with the user, if any.
Email() const
FIREBASE_DEPRECATED std::string
Deprecated. Renamed to email().
Gets email associated with the user, if any.
EmailVerified() const
FIREBASE_DEPRECATED bool
Deprecated. Renamed to is_email_verified().
Returns true if the email address associated with this user has been verified.
GetToken(bool force_refresh)
Future< std::string >
The Java Web Token (JWT) that can be used to identify the user to the backend.
GetTokenLastResult() const
Future< std::string >
Get results of the most recent call to Token.
LinkWithCredential(const Credential & credential)
Future< User * >
Links the user with the given 3rd party credentials.
LinkWithCredentialLastResult() const
Future< User * >
Get results of the most recent call to LinkWithCredential.
PhotoUrl() const
FIREBASE_DEPRECATED std::string
Deprecated. Renamed to photo_url().
Gets the photo url associated with the user, if any.
ProviderData() const
FIREBASE_DEPRECATED const std::vector< UserInfoInterface * > &
Deprecated. Renamed to provider_data().
Gets the third party profile data associated with this user returned by the authentication server, if any.
ProviderId() const
FIREBASE_DEPRECATED std::string
Deprecated. Renamed to provider_id().
Gets the provider ID for the user (For example, "Facebook").
Reauthenticate(const Credential & credential)
Future< void >
Reauthenticate using a credential.
ReauthenticateLastResult() const
Future< void >
Get results of the most recent call to UpdatePassword.
RefreshToken() const
FIREBASE_DEPRECATED std::string
Deprecated. Renamed to refresh_token().
Gets the raw refresh token (only for use in advanced scenarios where manually refresh of tokens is required).
Reload()
Future< void >
Refreshes the data for this user.
ReloadLastResult() const
Future< void >
Get results of the most recent call to Reload.
SendEmailVerification()
Future< void >
Initiates email verification for the user.
SendEmailVerificationLastResult() const
Future< void >
Get results of the most recent call to SendEmailVerification.
Token(bool force_refresh)
FIREBASE_DEPRECATED Future< std::string >
Deprecated. Renamed to GetToken().
The Java Web Token (JWT) that can be used to identify the user to the backend.
TokenLastResult() const
FIREBASE_DEPRECATED Future< std::string >
Deprecated. Renamed to GetTokenLastResult().
Get results of the most recent call to Token.
UID() const
FIREBASE_DEPRECATED std::string
Deprecated. Renamed to uid().
Gets the unique user ID for the user.
Unlink(const char *provider)
Future< User * >
Unlinks the current user from the provider specified.
UnlinkLastResult() const
Future< User * >
Get results of the most recent call to Unlink.
UpdateEmail(const char *email)
Future< void >
Sets the email address for the user.
UpdateEmailLastResult() const
Future< void >
Get results of the most recent call to UpdateEmail.
UpdatePassword(const char *password)
Future< void >
Attempts to change the password for the current user.
UpdatePasswordLastResult() const
Future< void >
Get results of the most recent call to UpdatePassword.
UpdateUserProfile(const UserProfile & profile)
Future< void >
Updates a subset of user profile information.
UpdateUserProfileLastResult() const
Future< void >
Get results of the most recent call to UpdateUserProfile.
display_name() const
virtual std::string
Gets the display name associated with the user, if any.
email() const
virtual std::string
Gets email associated with the user, if any.
is_anonymous() const
bool
Returns true if user signed in anonymously.
is_email_verified() const
bool
Returns true if the email address associated with this user has been verified.
photo_url() const
virtual std::string
Gets the photo url associated with the user, if any.
provider_data() const
const std::vector< UserInfoInterface * > &
Gets the third party profile data associated with this user returned by the authentication server, if any.
provider_id() const
virtual std::string
Gets the provider ID for the user (For example, "Facebook").
refresh_token() const
std::string
Gets the raw refresh token (only for use in advanced scenarios where manually refresh of tokens is required).
uid() const
virtual std::string
Gets the unique Firebase user ID for the user.

Structs

firebase::auth::User::UserProfile

Parameters to the UpdateUserProfile() function.

Public functions

Anonymous

FIREBASE_DEPRECATED bool Anonymous() const 

Returns true if user signed in anonymously.

Deprecated. Renamed to is_anonymous().

Delete

Future< void > Delete()

Deletes the user account.

DeleteLastResult

Future< void > DeleteLastResult() const 

Get results of the most recent call to Delete.

DisplayName

FIREBASE_DEPRECATED std::string DisplayName() const 

Gets the display name associated with the user, if any.

Deprecated. Renamed to display_name().

Email

FIREBASE_DEPRECATED std::string Email() const 

Gets email associated with the user, if any.

Deprecated. Renamed to email().

EmailVerified

FIREBASE_DEPRECATED bool EmailVerified() const 

Returns true if the email address associated with this user has been verified.

Deprecated. Renamed to is_email_verified().

GetToken

Future< std::string > GetToken(
  bool force_refresh
)

The Java Web Token (JWT) that can be used to identify the user to the backend.

If a current ID token is still believed to be valid (i.e. it has not yet expired), that token will be returned immediately. A developer may set the optional force_refresh flag to get a new ID token, whether or not the existing token has expired. For example, a developer may use this when they have discovered that the token is invalid for some other reason.

GetTokenLastResult

Future< std::string > GetTokenLastResult() const 

Get results of the most recent call to Token.

LinkWithCredential

Future< User * > LinkWithCredential(
  const Credential & credential
)

Links the user with the given 3rd party credentials.

For example, a Facebook login access token, a Twitter token/token-secret pair. Status will be an error if the token is invalid, expired, or otherwise not accepted by the server as well as if the given 3rd party user id is already linked with another user account or if the current user is already linked with another id from the same provider.

LinkWithCredentialLastResult

Future< User * > LinkWithCredentialLastResult() const 

Get results of the most recent call to LinkWithCredential.

PhotoUrl

FIREBASE_DEPRECATED std::string PhotoUrl() const 

Gets the photo url associated with the user, if any.

Deprecated. Renamed to photo_url().

ProviderData

FIREBASE_DEPRECATED const std::vector< UserInfoInterface * > & ProviderData() const 

Gets the third party profile data associated with this user returned by the authentication server, if any.

Deprecated. Renamed to provider_data().

ProviderId

FIREBASE_DEPRECATED std::string ProviderId() const 

Gets the provider ID for the user (For example, "Facebook").

Deprecated. Renamed to provider_id().

Reauthenticate

Future< void > Reauthenticate(
  const Credential & credential
)

Reauthenticate using a credential.

Some APIs (for example, UpdatePassword, Delete) require that the token used to invoke them be from a recent login attempt. This API takes an existing credential for the user and retrieves fresh tokens, ensuring that the operation can proceed. Developers can call this method prior to calling UpdatePassword() to ensure success.

Returns an error if the existing credential is not for this user or if sign-in with that credential failed. The user should remain signed in even if this method failed. If the developer had held a reference to that user, the reference will continue to be valid after this operation.

ReauthenticateLastResult

Future< void > ReauthenticateLastResult() const 

Get results of the most recent call to UpdatePassword.

RefreshToken

FIREBASE_DEPRECATED std::string RefreshToken() const 

Gets the raw refresh token (only for use in advanced scenarios where manually refresh of tokens is required).

Deprecated. Renamed to refresh_token().

Reload

Future< void > Reload()

Refreshes the data for this user.

For example, the attached providers, email address, display name, etc.

ReloadLastResult

Future< void > ReloadLastResult() const 

Get results of the most recent call to Reload.

SendEmailVerification

Future< void > SendEmailVerification()

Initiates email verification for the user.

SendEmailVerificationLastResult

Future< void > SendEmailVerificationLastResult() const 

Get results of the most recent call to SendEmailVerification.

Token

FIREBASE_DEPRECATED Future< std::string > Token(
  bool force_refresh
)

The Java Web Token (JWT) that can be used to identify the user to the backend.

If a current ID token is still believed to be valid (i.e. it has not yet expired), that token will be returned immediately. A developer may set the optional force_refresh flag to get a new ID token, whether or not the existing token has expired. For example, a developer may use this when they have discovered that the token is invalid for some other reason.

Deprecated. Renamed to GetToken().

TokenLastResult

FIREBASE_DEPRECATED Future< std::string > TokenLastResult() const 

Get results of the most recent call to Token.

Deprecated. Renamed to GetTokenLastResult().

UID

FIREBASE_DEPRECATED std::string UID() const 

Gets the unique user ID for the user.

Deprecated. Renamed to uid().

Unlink

Future< User * > Unlink(
  const char *provider
)

Unlinks the current user from the provider specified.

Status will be an error if the user is not linked to the given provider.

UnlinkLastResult

Future< User * > UnlinkLastResult() const 

Get results of the most recent call to Unlink.

UpdateEmail

Future< void > UpdateEmail(
  const char *email
)

Sets the email address for the user.

May fail if there is already an email/password-based account for the same email address.

UpdateEmailLastResult

Future< void > UpdateEmailLastResult() const 

Get results of the most recent call to UpdateEmail.

UpdatePassword

Future< void > UpdatePassword(
  const char *password
)

Attempts to change the password for the current user.

For an account linked to an Identity Provider (IDP) with no password, this will result in the account becoming an email/password-based account while maintaining the IDP link. May fail if the password is invalid, if there is a conflicting email/password-based account, or if the token has expired. To retrieve fresh tokens, call Reauthenticate.

UpdatePasswordLastResult

Future< void > UpdatePasswordLastResult() const 

Get results of the most recent call to UpdatePassword.

UpdateUserProfile

Future< void > UpdateUserProfile(
  const UserProfile & profile
)

Updates a subset of user profile information.

UpdateUserProfileLastResult

Future< void > UpdateUserProfileLastResult() const 

Get results of the most recent call to UpdateUserProfile.

display_name

virtual std::string display_name() const 

Gets the display name associated with the user, if any.

email

virtual std::string email() const 

Gets email associated with the user, if any.

is_anonymous

bool is_anonymous() const 

Returns true if user signed in anonymously.

is_email_verified

bool is_email_verified() const 

Returns true if the email address associated with this user has been verified.

photo_url

virtual std::string photo_url() const 

Gets the photo url associated with the user, if any.

provider_data

const std::vector< UserInfoInterface * > & provider_data() const 

Gets the third party profile data associated with this user returned by the authentication server, if any.

provider_id

virtual std::string provider_id() const 

Gets the provider ID for the user (For example, "Facebook").

refresh_token

std::string refresh_token() const 

Gets the raw refresh token (only for use in advanced scenarios where manually refresh of tokens is required).

uid

virtual std::string uid() const 

Gets the unique Firebase user ID for the user.

Note:The user's ID, unique to the Firebase project. Do NOT use this value to authenticate with your backend server, if you have one. Use User::GetToken() instead.

Send feedback about...

Need help? Visit our support page.