FirebaseAdmin.Auth.AbstractFirebaseAuth

Exposes Firebase Auth operations that are available in both tenant-aware and tenant-unaware contexts.

Summary

Inheritance

Inherits from: FirebaseAdmin.IFirebaseService
Direct Known Subclasses:FirebaseAdmin.Auth.FirebaseAuth, FirebaseAdmin.Auth.Multitenancy.TenantAwareFirebaseAuth

Public functions

CreateCustomTokenAsync(string uid)
async Task< string >
Creates a Firebase custom token for the given user ID.
CreateCustomTokenAsync(string uid, CancellationToken cancellationToken)
async Task< string >
Creates a Firebase custom token for the given user ID.
CreateCustomTokenAsync(string uid, IDictionary< string, object > developerClaims)
async Task< string >
Creates a Firebase custom token for the given user ID containing the specified additional claims.
CreateCustomTokenAsync(string uid, IDictionary< string, object > developerClaims, CancellationToken cancellationToken)
async Task< string >
Creates a Firebase custom token for the given user ID containing the specified additional claims.
CreateProviderConfigAsync< T >(AuthProviderConfigArgs< T > args)
async Task< T >
Creates a new auth provider configuration.
CreateProviderConfigAsync< T >(AuthProviderConfigArgs< T > args, CancellationToken cancellationToken)
async Task< T >
Creates a new auth provider configuration.
CreateUserAsync(UserRecordArgs args)
async Task< UserRecord >
Creates a new user account with the attributes contained in the specified UserRecordArgs.
CreateUserAsync(UserRecordArgs args, CancellationToken cancellationToken)
async Task< UserRecord >
Creates a new user account with the attributes contained in the specified UserRecordArgs.
DeleteProviderConfigAsync(string providerId)
async Task
Deletes the specified auth provider configuration.
DeleteProviderConfigAsync(string providerId, CancellationToken cancellationToken)
async Task
Deletes the specified auth provider configuration.
DeleteUserAsync(string uid)
async Task
Deletes the user identified by the specified uid .
DeleteUserAsync(string uid, CancellationToken cancellationToken)
async Task
Deletes the user identified by the specified uid .
DeleteUsersAsync(IReadOnlyList< string > uids)
async Task< DeleteUsersResult >
Deletes the users specified by the given identifiers.
DeleteUsersAsync(IReadOnlyList< string > uids, CancellationToken cancellationToken)
async Task< DeleteUsersResult >
Deletes the users specified by the given identifiers.
GenerateEmailVerificationLinkAsync(string email)
async Task< string >
Generates the out-of-band email action link for email verification flows for the specified email address.
GenerateEmailVerificationLinkAsync(string email, ActionCodeSettings settings)
async Task< string >
Generates the out-of-band email action link for email verification flows for the specified email address.
GenerateEmailVerificationLinkAsync(string email, ActionCodeSettings settings, CancellationToken cancellationToken)
async Task< string >
Generates the out-of-band email action link for email verification flows for the specified email address.
GeneratePasswordResetLinkAsync(string email)
async Task< string >
Generates the out-of-band email action link for password reset flows for the specified email address.
GeneratePasswordResetLinkAsync(string email, ActionCodeSettings settings)
async Task< string >
Generates the out-of-band email action link for password reset flows for the specified email address.
GeneratePasswordResetLinkAsync(string email, ActionCodeSettings settings, CancellationToken cancellationToken)
async Task< string >
Generates the out-of-band email action link for password reset flows for the specified email address.
GenerateSignInWithEmailLinkAsync(string email, ActionCodeSettings settings)
async Task< string >
Generates the out-of-band email action link for email link sign-in flows for the specified email address.
GenerateSignInWithEmailLinkAsync(string email, ActionCodeSettings settings, CancellationToken cancellationToken)
async Task< string >
Generates the out-of-band email action link for email link sign-in flows for the specified email address.
GetOidcProviderConfigAsync(string providerId)
async Task< OidcProviderConfig >
Looks up an OIDC auth provider configuration by the provided ID.
GetOidcProviderConfigAsync(string providerId, CancellationToken cancellationToken)
async Task< OidcProviderConfig >
Looks up an OIDC auth provider configuration by the provided ID.
GetSamlProviderConfigAsync(string providerId)
async Task< SamlProviderConfig >
Looks up a SAML auth provider configuration by the provided ID.
GetSamlProviderConfigAsync(string providerId, CancellationToken cancellationToken)
async Task< SamlProviderConfig >
Looks up a SAML auth provider configuration by the provided ID.
GetUserAsync(string uid)
async Task< UserRecord >
Gets a UserRecord object containing information about the user who's user ID was specified in uid .
GetUserAsync(string uid, CancellationToken cancellationToken)
async Task< UserRecord >
Gets a UserRecord object containing information about the user who's user ID was specified in uid .
GetUserByEmailAsync(string email)
async Task< UserRecord >
Gets a UserRecord object containing information about the user identified by email .
GetUserByEmailAsync(string email, CancellationToken cancellationToken)
async Task< UserRecord >
Gets a UserRecord object containing information about the user identified by email .
GetUserByPhoneNumberAsync(string phoneNumber)
async Task< UserRecord >
Gets a UserRecord object containing information about the user identified by phoneNumber .
GetUserByPhoneNumberAsync(string phoneNumber, CancellationToken cancellationToken)
async Task< UserRecord >
Gets a UserRecord object containing information about the user identified by phoneNumber .
GetUsersAsync(IReadOnlyCollection< UserIdentifier > identifiers)
async Task< GetUsersResult >
Gets the user data corresponding to the specified identifiers.
GetUsersAsync(IReadOnlyCollection< UserIdentifier > identifiers, CancellationToken cancellationToken)
async Task< GetUsersResult >
Gets the user data corresponding to the specified identifiers.
ImportUsersAsync(IEnumerable< ImportUserRecordArgs > users)
async Task< UserImportResult >
Imports the provided list of users into Firebase Auth.
ImportUsersAsync(IEnumerable< ImportUserRecordArgs > users, CancellationToken cancellationToken)
async Task< UserImportResult >
Imports the provided list of users into Firebase Auth.
ImportUsersAsync(IEnumerable< ImportUserRecordArgs > users, UserImportOptions options)
async Task< UserImportResult >
Imports the provided list of users into Firebase Auth.
ImportUsersAsync(IEnumerable< ImportUserRecordArgs > users, UserImportOptions options, CancellationToken cancellationToken)
async Task< UserImportResult >
Imports the provided list of users into Firebase Auth.
ListOidcProviderConfigsAsync(ListProviderConfigsOptions options)
PagedAsyncEnumerable< AuthProviderConfigs< OidcProviderConfig >, OidcProviderConfig >
Gets an async enumerable to iterate or page through OIDC provider configurations starting from the specified page token.
ListSamlProviderConfigsAsync(ListProviderConfigsOptions options)
PagedAsyncEnumerable< AuthProviderConfigs< SamlProviderConfig >, SamlProviderConfig >
Gets an async enumerable to iterate or page through SAML provider configurations starting from the specified page token.
ListUsersAsync(ListUsersOptions options)
PagedAsyncEnumerable< ExportedUserRecords, ExportedUserRecord >
Gets an async enumerable to iterate or page through users starting from the specified page token.
RevokeRefreshTokensAsync(string uid)
async Task
Revokes all refresh tokens for the specified user.
RevokeRefreshTokensAsync(string uid, CancellationToken cancellationToken)
async Task
Revokes all refresh tokens for the specified user.
SetCustomUserClaimsAsync(string uid, IReadOnlyDictionary< string, object > claims)
async Task
Sets the specified custom claims on an existing user account.
SetCustomUserClaimsAsync(string uid, IReadOnlyDictionary< string, object > claims, CancellationToken cancellationToken)
async Task
Sets the specified custom claims on an existing user account.
UpdateProviderConfigAsync< T >(AuthProviderConfigArgs< T > args)
async Task< T >
Updates an existing auth provider configuration.
UpdateProviderConfigAsync< T >(AuthProviderConfigArgs< T > args, CancellationToken cancellationToken)
async Task< T >
Updates an existing auth provider configuration.
UpdateUserAsync(UserRecordArgs args)
async Task< UserRecord >
Updates an existing user account with the attributes contained in the specified UserRecordArgs.
UpdateUserAsync(UserRecordArgs args, CancellationToken cancellationToken)
async Task< UserRecord >
Updates an existing user account with the attributes contained in the specified UserRecordArgs.
VerifyIdTokenAsync(string idToken)
async Task< FirebaseToken >
Parses and verifies a Firebase ID token.
VerifyIdTokenAsync(string idToken, CancellationToken cancellationToken)
async Task< FirebaseToken >
Parses and verifies a Firebase ID token.
VerifyIdTokenAsync(string idToken, bool checkRevoked)
async Task< FirebaseToken >
Parses and verifies a Firebase ID token.
VerifyIdTokenAsync(string idToken, bool checkRevoked, CancellationToken cancellationToken)
async Task< FirebaseToken >
Parses and verifies a Firebase ID token.

Protected functions

IfNotDeleted< TResult >(Func< TResult > func)
TResult
IsRevokedAsync(FirebaseToken token, CancellationToken cancellationToken)
async Task< bool >

Public functions

CreateCustomTokenAsync

async Task< string > CreateCustomTokenAsync(
  string uid
)

Creates a Firebase custom token for the given user ID.

This token can then be sent back to a client application to be used with the signInWithCustomToken authentication API.

This method attempts to generate a token using:

  1. the private key of FirebaseApp's service account credentials, if provided at initialization.
  2. the IAM service if a service accound ID was specified via AppOptions
  3. the local metadata server if the code is deployed in a GCP-managed environment.

Details
Exceptions
ArgumentException
If uid is null, empty or longer than 128 characters.
InvalidOperationException
If no service account can be discovered from either the AppOptions or the deployment environment.
FirebaseAuthException
If an error occurs while creating a custom token.
Parameters
uid
The UID to store in the token. This identifies the user to other Firebase services (Realtime Database, Firebase Auth, etc.). Must not be longer than 128 characters.
Returns
A task that completes with a Firebase custom token.

CreateCustomTokenAsync

async Task< string > CreateCustomTokenAsync(
  string uid,
  CancellationToken cancellationToken
)

Creates a Firebase custom token for the given user ID.

This token can then be sent back to a client application to be used with the signInWithCustomToken authentication API.

This method attempts to generate a token using:

  1. the private key of FirebaseApp's service account credentials, if provided at initialization.
  2. the IAM service if a service accound ID was specified via AppOptions
  3. the local metadata server if the code is deployed in a GCP-managed environment.

Details
Exceptions
ArgumentException
If uid is null, empty or longer than 128 characters.
InvalidOperationException
If no service account can be discovered from either the AppOptions or the deployment environment.
FirebaseAuthException
If an error occurs while creating a custom token.
Parameters
uid
The UID to store in the token. This identifies the user to other Firebase services (Realtime Database, Firebase Auth, etc.). Must not be longer than 128 characters.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a Firebase custom token.

CreateCustomTokenAsync

async Task< string > CreateCustomTokenAsync(
  string uid,
  IDictionary< string, object > developerClaims
)

Creates a Firebase custom token for the given user ID containing the specified additional claims.

This token can then be sent back to a client application to be used with the signInWithCustomToken authentication API.

This method uses the same mechanisms as CreateCustomTokenAsync(string) to sign custom tokens.

Details
Exceptions
ArgumentException
If uid is null, empty or longer than 128 characters. Or, if developerClaims contains any standard JWT claims.
InvalidOperationException
If no service account can be discovered from either the AppOptions or the deployment environment.
FirebaseAuthException
If an error occurs while creating a custom token.
Parameters
uid
The UID to store in the token. This identifies the user to other Firebase services (Realtime Database, Firebase Auth, etc.). Must not be longer than 128 characters.
developerClaims
Additional claims to be stored in the token, and made available to Firebase security rules. These must be serializable to JSON, and must not contain any standard JWT claims.
Returns
A task that completes with a Firebase custom token.

CreateCustomTokenAsync

async Task< string > CreateCustomTokenAsync(
  string uid,
  IDictionary< string, object > developerClaims,
  CancellationToken cancellationToken
)

Creates a Firebase custom token for the given user ID containing the specified additional claims.

This token can then be sent back to a client application to be used with the signInWithCustomToken authentication API.

This method uses the same mechanisms as CreateCustomTokenAsync(string) to sign custom tokens.

Details
Exceptions
ArgumentException
If uid is null, empty or longer than 128 characters. Or, if developerClaims contains any standard JWT claims.
InvalidOperationException
If no service account can be discovered from either the AppOptions or the deployment environment.
FirebaseAuthException
If an error occurs while creating a custom token.
Parameters
uid
The UID to store in the token. This identifies the user to other Firebase services (Realtime Database, Firebase Auth, etc.). Must not be longer than 128 characters.
developerClaims
Additional claims to be stored in the token, and made available to Firebase security rules. These must be serializable to JSON, and must not contain any standard JWT claims.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a Firebase custom token.

CreateProviderConfigAsync< T >

async Task< T > CreateProviderConfigAsync< T >(
  AuthProviderConfigArgs< T > args
)

Creates a new auth provider configuration.

Details
Exceptions
ArgumentException
If args is null or invalid.
FirebaseAuthException
If an unexpected error occurs while creating the provider configuration.
Parameters
args
Arguments that describe the new provider configuration.
Template Parameters
T
Type of AuthProviderConfig to create.
Returns
A task that completes with an AuthProviderConfig.

CreateProviderConfigAsync< T >

async Task< T > CreateProviderConfigAsync< T >(
  AuthProviderConfigArgs< T > args,
  CancellationToken cancellationToken
)

Creates a new auth provider configuration.

Details
Exceptions
ArgumentException
If args is null or invalid.
FirebaseAuthException
If an unexpected error occurs while creating the provider configuration.
Parameters
args
Arguments that describe the new provider configuration.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Template Parameters
T
Type of AuthProviderConfig to create.
Returns
A task that completes with an AuthProviderConfig.

CreateUserAsync

async Task< UserRecord > CreateUserAsync(
  UserRecordArgs args
)

Creates a new user account with the attributes contained in the specified UserRecordArgs.

Details
Parameters
args
Attributes to add to the new user account.
Exceptions
ArgumentNullException
If args is null.
ArgumentException
If any of the values in args are invalid.
FirebaseAuthException
If an error occurs while creating the user account.
Returns
A task that completes with a UserRecord representing the newly created user account.

CreateUserAsync

async Task< UserRecord > CreateUserAsync(
  UserRecordArgs args,
  CancellationToken cancellationToken
)

Creates a new user account with the attributes contained in the specified UserRecordArgs.

Details
Parameters
args
Attributes to add to the new user account.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentNullException
If args is null.
ArgumentException
If any of the values in args are invalid.
FirebaseAuthException
If an error occurs while creating the user account.
Returns
A task that completes with a UserRecord representing the newly created user account.

DeleteProviderConfigAsync

async Task DeleteProviderConfigAsync(
  string providerId
)

Deletes the specified auth provider configuration.

Details
Exceptions
ArgumentException
If the provider ID is null, empty or does not contain either the oidc. or saml. prefix.
FirebaseAuthException
If the specified provider config does not exist.
Parameters
providerId
ID of the provider configuration to delete.
Returns
A task that completes when the provider configuration is deleted.

DeleteProviderConfigAsync

async Task DeleteProviderConfigAsync(
  string providerId,
  CancellationToken cancellationToken
)

Deletes the specified auth provider configuration.

Details
Exceptions
ArgumentException
If the provider ID is null, empty or does not contain either the oidc. or saml. prefix.
FirebaseAuthException
If the specified provider config does not exist.
Parameters
providerId
ID of the provider configuration to delete.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes when the provider configuration is deleted.

DeleteUserAsync

async Task DeleteUserAsync(
  string uid
)

Deletes the user identified by the specified uid .

Details
Parameters
uid
A user ID string.
Exceptions
ArgumentException
If the user ID argument is null or empty.
FirebaseAuthException
If an error occurs while deleting the user.
Returns
A task that completes when the user account has been deleted.

DeleteUserAsync

async Task DeleteUserAsync(
  string uid,
  CancellationToken cancellationToken
)

Deletes the user identified by the specified uid .

Details
Parameters
uid
A user ID string.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If the user ID argument is null or empty.
FirebaseAuthException
If an error occurs while deleting the user.
Returns
A task that completes when the user account has been deleted.

DeleteUsersAsync

async Task< DeleteUsersResult > DeleteUsersAsync(
  IReadOnlyList< string > uids
)

Deletes the users specified by the given identifiers.

Deleting a non-existing user won't generate an error. (i.e. this method is idempotent.) Non-existing users will be considered to be successfully deleted, and will therefore be counted in the DeleteUserResult.SuccessCount value.

A maximum of 1000 identifiers may be supplied. If more than 1000 identifiers are specified, this method throws an ArgumentException.

This API is currently rate limited at the server to 1 QPS. If you exceed this, you may get a quota exceeded error. Therefore, if you want to delete more than 1000 users, you may need to add a delay to ensure you don't go over this limit.

Details
Parameters
uids
The uids of the users to be deleted. Must have 1000 or fewer entries.
Exceptions
ArgumentException
If any of the identifiers are invalid or if more than 1000 identifiers are specified.
Returns
A task that resolves to the total number of successful/failed deletions, as well as the array of errors that correspond to the failed deletions.

DeleteUsersAsync

async Task< DeleteUsersResult > DeleteUsersAsync(
  IReadOnlyList< string > uids,
  CancellationToken cancellationToken
)

Deletes the users specified by the given identifiers.

Deleting a non-existing user won't generate an error. (i.e. this method is idempotent.) Non-existing users will be considered to be successfully deleted, and will therefore be counted in the DeleteUserResult.SuccessCount value.

A maximum of 1000 identifiers may be supplied. If more than 1000 identifiers are specified, this method throws an ArgumentException.

This API is currently rate limited at the server to 1 QPS. If you exceed this, you may get a quota exceeded error. Therefore, if you want to delete more than 1000 users, you may need to add a delay to ensure you don't go over this limit.

Details
Parameters
uids
The uids of the users to be deleted. Must have 1000 or fewer entries.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If any of the identifiers are invalid or if more than 1000 identifiers are specified.
Returns
A task that resolves to the total number of successful/failed deletions, as well as the array of errors that correspond to the failed deletions.

GenerateEmailVerificationLinkAsync

async Task< string > GenerateEmailVerificationLinkAsync(
  string email
)

Generates the out-of-band email action link for email verification flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while generating the link.
Parameters
email
The email of the user to be verified.
Returns
A task that completes with the email verification link.

GenerateEmailVerificationLinkAsync

async Task< string > GenerateEmailVerificationLinkAsync(
  string email,
  ActionCodeSettings settings
)

Generates the out-of-band email action link for email verification flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while generating the link.
Parameters
email
The email of the user to be verifed.
settings
The action code settings object that defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link.
Returns
A task that completes with the email verification link.

GenerateEmailVerificationLinkAsync

async Task< string > GenerateEmailVerificationLinkAsync(
  string email,
  ActionCodeSettings settings,
  CancellationToken cancellationToken
)

Generates the out-of-band email action link for email verification flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while generating the link.
Parameters
email
The email of the user to be verified.
settings
The action code settings object that defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with the email verification reset link.

GeneratePasswordResetLinkAsync

async Task< string > GeneratePasswordResetLinkAsync(
  string email
)

Generates the out-of-band email action link for password reset flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while setting custom claims.
Parameters
email
The email of the user whose password is to be reset.
Returns
A task that completes with the password reset link.

GeneratePasswordResetLinkAsync

async Task< string > GeneratePasswordResetLinkAsync(
  string email,
  ActionCodeSettings settings
)

Generates the out-of-band email action link for password reset flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while setting custom claims.
Parameters
email
The email of the user whose password is to be reset.
settings
The action code settings object that defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link.
Returns
A task that completes with the password reset link.

GeneratePasswordResetLinkAsync

async Task< string > GeneratePasswordResetLinkAsync(
  string email,
  ActionCodeSettings settings,
  CancellationToken cancellationToken
)

Generates the out-of-band email action link for password reset flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while setting custom claims.
Parameters
email
The email of the user whose password is to be reset.
settings
The action code settings object that defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with the password reset link.

GenerateSignInWithEmailLinkAsync

async Task< string > GenerateSignInWithEmailLinkAsync(
  string email,
  ActionCodeSettings settings
)

Generates the out-of-band email action link for email link sign-in flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while generating the link.
Parameters
email
The email of the user signing in.
settings
The action code settings object that defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link.
Returns
A task that completes with the email sign in link.

GenerateSignInWithEmailLinkAsync

async Task< string > GenerateSignInWithEmailLinkAsync(
  string email,
  ActionCodeSettings settings,
  CancellationToken cancellationToken
)

Generates the out-of-band email action link for email link sign-in flows for the specified email address.

Details
Exceptions
FirebaseAuthException
If an error occurs while generating the link.
Parameters
email
The email of the user signing in.
settings
The action code settings object that defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with the email sign in link.

GetOidcProviderConfigAsync

async Task< OidcProviderConfig > GetOidcProviderConfigAsync(
  string providerId
)

Looks up an OIDC auth provider configuration by the provided ID.

Details
Exceptions
ArgumentException
If the provider ID is null, empty or does not contain the oidc. prefix.
FirebaseAuthException
If the specified provider config does not exist.
Parameters
providerId
The ID of the OIDC provider config to return.
Returns
A task that completes with a OidcProviderConfig.

GetOidcProviderConfigAsync

async Task< OidcProviderConfig > GetOidcProviderConfigAsync(
  string providerId,
  CancellationToken cancellationToken
)

Looks up an OIDC auth provider configuration by the provided ID.

Details
Exceptions
ArgumentException
If the provider ID is null, empty or does not contain the oidc. prefix.
FirebaseAuthException
If the specified provider config does not exist.
Parameters
providerId
The ID of the OIDC provider config to return.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a OidcProviderConfig.

GetSamlProviderConfigAsync

async Task< SamlProviderConfig > GetSamlProviderConfigAsync(
  string providerId
)

Looks up a SAML auth provider configuration by the provided ID.

Details
Exceptions
ArgumentException
If the provider ID is null, empty or does not contain the saml. prefix.
FirebaseAuthException
If the specified provider config does not exist.
Parameters
providerId
The ID of the SAML provider config to return.
Returns
A task that completes with a SamlProviderConfig.

GetSamlProviderConfigAsync

async Task< SamlProviderConfig > GetSamlProviderConfigAsync(
  string providerId,
  CancellationToken cancellationToken
)

Looks up a SAML auth provider configuration by the provided ID.

Details
Exceptions
ArgumentException
If the provider ID is null, empty or does not contain the saml. prefix.
FirebaseAuthException
If the specified provider config does not exist.
Parameters
providerId
The ID of the SAML provider config to return.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a SamlProviderConfig.

GetUserAsync

async Task< UserRecord > GetUserAsync(
  string uid
)

Gets a UserRecord object containing information about the user who's user ID was specified in uid .

Details
Parameters
uid
The user ID for the user who's data is to be retrieved.
Exceptions
ArgumentException
If user ID argument is null or empty.
FirebaseAuthException
If a user cannot be found with the specified user ID.
Returns
A task that completes with a UserRecord representing a user with the specified user ID.

GetUserAsync

async Task< UserRecord > GetUserAsync(
  string uid,
  CancellationToken cancellationToken
)

Gets a UserRecord object containing information about the user who's user ID was specified in uid .

Details
Parameters
uid
The user ID for the user who's data is to be retrieved.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If user ID argument is null or empty.
FirebaseAuthException
If a user cannot be found with the specified user ID.
Returns
A task that completes with a UserRecord representing a user with the specified user ID.

GetUserByEmailAsync

async Task< UserRecord > GetUserByEmailAsync(
  string email
)

Gets a UserRecord object containing information about the user identified by email .

Details
Parameters
email
The email of the user who's data is to be retrieved.
Exceptions
ArgumentException
If the email argument is null or empty.
FirebaseAuthException
If a user cannot be found with the specified email.
Returns
A task that completes with a UserRecord representing a user with the specified email.

GetUserByEmailAsync

async Task< UserRecord > GetUserByEmailAsync(
  string email,
  CancellationToken cancellationToken
)

Gets a UserRecord object containing information about the user identified by email .

Details
Parameters
email
The email of the user who's data is to be retrieved.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If the email argument is null or empty.
FirebaseAuthException
If a user cannot be found with the specified email.
Returns
A task that completes with a UserRecord representing a user with the specified email.

GetUserByPhoneNumberAsync

async Task< UserRecord > GetUserByPhoneNumberAsync(
  string phoneNumber
)

Gets a UserRecord object containing information about the user identified by phoneNumber .

Details
Parameters
phoneNumber
The phone number of the user who's data is to be retrieved.
Exceptions
ArgumentException
If the phone number argument is null or empty.
FirebaseAuthException
If a user cannot be found with the specified phone number.
Returns
A task that completes with a UserRecord representing a user with the specified phone number.

GetUserByPhoneNumberAsync

async Task< UserRecord > GetUserByPhoneNumberAsync(
  string phoneNumber,
  CancellationToken cancellationToken
)

Gets a UserRecord object containing information about the user identified by phoneNumber .

Details
Parameters
phoneNumber
The phone number of the user who's data is to be retrieved.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If the phone number argument is null or empty.
FirebaseAuthException
If a user cannot be found with the specified phone number.
Returns
A task that completes with a UserRecord representing a user with the specified phone number.

GetUsersAsync

async Task< GetUsersResult > GetUsersAsync(
  IReadOnlyCollection< UserIdentifier > identifiers
)

Gets the user data corresponding to the specified identifiers.

There are no ordering guarantees; in particular, the nth entry in the users result list is not guaranteed to correspond to the nth entry in the input parameters list.

A maximum of 100 identifiers may be supplied. If more than 100 identifiers are specified, this method throws an ArgumentException.

Details
Parameters
identifiers
The identifiers used to indicate which user records should be returned. Must have 100 entries or fewer.
Exceptions
ArgumentException
If any of the identifiers are invalid or if more than 100 identifiers are specified.
Returns
A task that resolves to the corresponding user records.

GetUsersAsync

async Task< GetUsersResult > GetUsersAsync(
  IReadOnlyCollection< UserIdentifier > identifiers,
  CancellationToken cancellationToken
)

Gets the user data corresponding to the specified identifiers.

There are no ordering guarantees; in particular, the nth entry in the users result list is not guaranteed to correspond to the nth entry in the input parameters list.

A maximum of 100 identifiers may be supplied. If more than 100 identifiers are specified, this method throws an ArgumentException.

Details
Parameters
identifiers
The identifiers used to indicate which user records should be returned. Must have 100 entries or fewer.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If any of the identifiers are invalid or if more than 100 identifiers are specified.
Returns
A task that resolves to the corresponding user records.

ImportUsersAsync

async Task< UserImportResult > ImportUsersAsync(
  IEnumerable< ImportUserRecordArgs > users
)

Imports the provided list of users into Firebase Auth.

You can import a maximum of 1000 users at a time. This operation is optimized for bulk imports and does not check identifier uniqueness, which could result in duplications.

UserImportOptions is required to import users with passwords. See FirebaseAuth.ImportUsersAsync.

Details
Parameters
users
A non-empty list of users to be imported. Length must not exceed 1000.
Exceptions
ArgumentException
If the users list is null, empty or has more than 1000 elements. Or if at least one user specifies a password, with no hashing algorithm set.
FirebaseAuthException
If an error occurs while importing users.
Returns
A UserImportResult instance.

ImportUsersAsync

async Task< UserImportResult > ImportUsersAsync(
  IEnumerable< ImportUserRecordArgs > users,
  CancellationToken cancellationToken
)

Imports the provided list of users into Firebase Auth.

You can import a maximum of 1000 users at a time. This operation is optimized for bulk imports and does not check identifier uniqueness, which could result in duplications.

UserImportOptions is required to import users with passwords. See FirebaseAuth.ImportUsersAsync.

Details
Parameters
users
A non-empty list of users to be imported. Length must not exceed 1000.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If the users list is null, empty or has more than 1000 elements. Or if at least one user specifies a password, with no hashing algorithm set.
FirebaseAuthException
If an error occurs while importing users.
Returns
A UserImportResult instance.

ImportUsersAsync

async Task< UserImportResult > ImportUsersAsync(
  IEnumerable< ImportUserRecordArgs > users,
  UserImportOptions options
)

Imports the provided list of users into Firebase Auth.

You can import a maximum of 1000 users at a time. This operation is optimized for bulk imports and does not check identifier uniqueness, which could result in duplications.

Details
Parameters
users
A non-empty list of users to be imported. Length must not exceed 1000.
options
A UserImportOptions instance or null. Required when importing users with passwords.
Exceptions
ArgumentException
If the users list is null, empty or has more than 1000 elements. Or if at least one user specifies a password, with no hashing algorithm set.
FirebaseAuthException
If an error occurs while importing users.
Returns
A UserImportResult instance.

ImportUsersAsync

async Task< UserImportResult > ImportUsersAsync(
  IEnumerable< ImportUserRecordArgs > users,
  UserImportOptions options,
  CancellationToken cancellationToken
)

Imports the provided list of users into Firebase Auth.

You can import a maximum of 1000 users at a time. This operation is optimized for bulk imports and does not check identifier uniqueness, which could result in duplications.

Details
Parameters
users
A non-empty list of users to be imported. Length must not exceed 1000.
options
A UserImportOptions instance or null. Required when importing users with passwords.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If the users list is null, empty or has more than 1000 elements. Or if at least one user specifies a password, with no hashing algorithm set.
FirebaseAuthException
If an error occurs while importing users.
Returns
A UserImportResult instance.

ListOidcProviderConfigsAsync

PagedAsyncEnumerable< AuthProviderConfigs< OidcProviderConfig >, OidcProviderConfig > ListOidcProviderConfigsAsync(
  ListProviderConfigsOptions options
)

Gets an async enumerable to iterate or page through OIDC provider configurations starting from the specified page token.

If the page token is null or unspecified, iteration starts from the first page. See Page Streaming for more details on how to use this API.

Details
Parameters
options
The options to control the starting point and page size. Pass null to list from the beginning with default settings.
Returns
A PagedAsyncEnumerable{AuthProviderConfigs, OidcProviderConfig} instance.

ListSamlProviderConfigsAsync

PagedAsyncEnumerable< AuthProviderConfigs< SamlProviderConfig >, SamlProviderConfig > ListSamlProviderConfigsAsync(
  ListProviderConfigsOptions options
)

Gets an async enumerable to iterate or page through SAML provider configurations starting from the specified page token.

If the page token is null or unspecified, iteration starts from the first page. See Page Streaming for more details on how to use this API.

Details
Parameters
options
The options to control the starting point and page size. Pass null to list from the beginning with default settings.
Returns
A PagedAsyncEnumerable{AuthProviderConfigs, SamlProviderConfig} instance.

ListUsersAsync

PagedAsyncEnumerable< ExportedUserRecords, ExportedUserRecord > ListUsersAsync(
  ListUsersOptions options
)

Gets an async enumerable to iterate or page through users starting from the specified page token.

If the page token is null or unspecified, iteration starts from the first page. See Page Streaming for more details on how to use this API.

Details
Parameters
options
The options to control the starting point and page size. Pass null to list from the beginning with default settings.
Returns
A PagedAsyncEnumerable{ExportedUserRecords, ExportedUserRecord} instance.

RevokeRefreshTokensAsync

async Task RevokeRefreshTokensAsync(
  string uid
)

Revokes all refresh tokens for the specified user.

Updates the user's tokensValidAfterTimestamp to the current UTC time expressed in seconds since the epoch and truncated to 1 second accuracy. It is important that the server on which this is called has its clock set correctly and synchronized.

While this will revoke all sessions for a specified user and disable any new ID tokens for existing sessions from getting minted, existing ID tokens may remain active until their natural expiration (one hour).

Details
Parameters
uid
A user ID string.
Exceptions
ArgumentException
If the user ID argument is null or empty.
FirebaseAuthException
If an error occurs while revoking the tokens.
Returns
A task that completes when the user's refresh tokens have been revoked.

RevokeRefreshTokensAsync

async Task RevokeRefreshTokensAsync(
  string uid,
  CancellationToken cancellationToken
)

Revokes all refresh tokens for the specified user.

Updates the user's tokensValidAfterTimestamp to the current UTC time expressed in seconds since the epoch and truncated to 1 second accuracy. It is important that the server on which this is called has its clock set correctly and synchronized.

While this will revoke all sessions for a specified user and disable any new ID tokens for existing sessions from getting minted, existing ID tokens may remain active until their natural expiration (one hour).

Details
Parameters
uid
A user ID string.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentException
If the user ID argument is null or empty.
FirebaseAuthException
If an error occurs while revoking the tokens.
Returns
A task that completes when the user's refresh tokens have been revoked.

SetCustomUserClaimsAsync

async Task SetCustomUserClaimsAsync(
  string uid,
  IReadOnlyDictionary< string, object > claims
)

Sets the specified custom claims on an existing user account.

A null claims value removes any claims currently set on the user account. The claims must serialize into a valid JSON string. The serialized claims must not be larger than 1000 characters.

Details
Exceptions
ArgumentException
If uid is null, empty or longer than 128 characters. Or, if the serialized claims is larger than 1000 characters.
FirebaseAuthException
If an error occurs while setting custom claims.
Parameters
uid
The user ID string for the custom claims will be set. Must not be null or longer than 128 characters.
claims
The claims to be stored on the user account, and made available to Firebase security rules. These must be serializable to JSON, and the serialized claims should not be larger than 1000 characters.
Returns
A task that completes when the claims have been set.

SetCustomUserClaimsAsync

async Task SetCustomUserClaimsAsync(
  string uid,
  IReadOnlyDictionary< string, object > claims,
  CancellationToken cancellationToken
)

Sets the specified custom claims on an existing user account.

A null claims value removes any claims currently set on the user account. The claims should serialize into a valid JSON string. The serialized claims must not be larger than 1000 characters.

Details
Exceptions
ArgumentException
If uid is null, empty or longer than 128 characters. Or, if the serialized claims is larger than 1000 characters.
FirebaseAuthException
If an error occurs while setting custom claims.
Parameters
uid
The user ID string for the custom claims will be set. Must not be null or longer than 128 characters.
claims
The claims to be stored on the user account, and made available to Firebase security rules. These must be serializable to JSON, and after serialization it should not be larger than 1000 characters.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes when the claims have been set.

UpdateProviderConfigAsync< T >

async Task< T > UpdateProviderConfigAsync< T >(
  AuthProviderConfigArgs< T > args
)

Updates an existing auth provider configuration.

Details
Exceptions
ArgumentException
If args is null or invalid.
FirebaseAuthException
If the specified provider config does not exist or if an unexpected error occurs while performing the update.
Parameters
args
Properties to be updated in the provider configuration.
Template Parameters
T
Type of AuthProviderConfig to update.
Returns
A task that completes with the updated AuthProviderConfig.

UpdateProviderConfigAsync< T >

async Task< T > UpdateProviderConfigAsync< T >(
  AuthProviderConfigArgs< T > args,
  CancellationToken cancellationToken
)

Updates an existing auth provider configuration.

Details
Exceptions
ArgumentException
If args is null or invalid.
FirebaseAuthException
If the specified provider config does not exist or if an unexpected error occurs while performing the update.
Parameters
args
Properties to be updated in the provider configuration.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Template Parameters
T
Type of AuthProviderConfig to update.
Returns
A task that completes with the updated AuthProviderConfig.

UpdateUserAsync

async Task< UserRecord > UpdateUserAsync(
  UserRecordArgs args
)

Updates an existing user account with the attributes contained in the specified UserRecordArgs.

The UserRecordArgs.Uid property must be specified.

Details
Parameters
args
The attributes to update.
Exceptions
ArgumentNullException
If args is null.
ArgumentException
If any of the values in args are invalid.
FirebaseAuthException
If an error occurs while updating the user account.
Returns
A task that completes with a UserRecord representing the updated user account.

UpdateUserAsync

async Task< UserRecord > UpdateUserAsync(
  UserRecordArgs args,
  CancellationToken cancellationToken
)

Updates an existing user account with the attributes contained in the specified UserRecordArgs.

The UserRecordArgs.Uid property must be specified.

Details
Parameters
args
The attributes to update.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Exceptions
ArgumentNullException
If args is null.
ArgumentException
If any of the values in args are invalid.
FirebaseAuthException
If an error occurs while updating the user account.
Returns
A task that completes with a UserRecord representing the updated user account.

VerifyIdTokenAsync

async Task< FirebaseToken > VerifyIdTokenAsync(
  string idToken
)

Parses and verifies a Firebase ID token.

A Firebase client app can identify itself to a trusted backend server by sending its Firebase ID Token (accessible via the getIdToken() API in the Firebase client SDK) with its requests. The backend server can then use this method to verify that the token is valid. This method ensures that the token is correctly signed, has not expired, and it was issued against the Firebase project associated with this FirebaseAuth instance.

See Verify ID Tokens for code samples and detailed documentation.

Details
Exceptions
ArgumentException
If ID token argument is null or empty.
FirebaseAuthException
If the ID token fails to verify.
Parameters
idToken
A Firebase ID token string to parse and verify.
Returns
A task that completes with a FirebaseToken representing the verified and decoded ID token.

VerifyIdTokenAsync

async Task< FirebaseToken > VerifyIdTokenAsync(
  string idToken,
  CancellationToken cancellationToken
)

Parses and verifies a Firebase ID token.

A Firebase client app can identify itself to a trusted backend server by sending its Firebase ID Token (accessible via the getIdToken() API in the Firebase client SDK) with its requests. The backend server can then use this method to verify that the token is valid. This method ensures that the token is correctly signed, has not expired, and it was issued against the Firebase project associated with this FirebaseAuth instance.

See Verify ID Tokens for code samples and detailed documentation.

Details
Exceptions
ArgumentException
If ID token argument is null or empty.
FirebaseAuthException
If the ID token fails to verify.
Parameters
idToken
A Firebase ID token string to parse and verify.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a FirebaseToken representing the verified and decoded ID token.

VerifyIdTokenAsync

async Task< FirebaseToken > VerifyIdTokenAsync(
  string idToken,
  bool checkRevoked
)

Parses and verifies a Firebase ID token.

A Firebase client app can identify itself to a trusted backend server by sending its Firebase ID Token (accessible via the getIdToken() API in the Firebase client SDK) with its requests. The backend server can then use this method to verify that the token is valid. This method ensures that the token is correctly signed, has not expired, and it was issued against the Firebase project associated with this FirebaseAuth instance.

If checkRevoked is set to true, this method performs an additional check to see if the ID token has been revoked since it was issued. This requires making an additional remote API call.

See Verify ID Tokens for code samples and detailed documentation.

Details
Exceptions
ArgumentException
If ID token argument is null or empty.
FirebaseAuthException
If the ID token fails to verify.
Parameters
idToken
A Firebase ID token string to parse and verify.
checkRevoked
A boolean indicating whether to check if the tokens were revoked.
Returns
A task that completes with a FirebaseToken representing the verified and decoded ID token.

VerifyIdTokenAsync

async Task< FirebaseToken > VerifyIdTokenAsync(
  string idToken,
  bool checkRevoked,
  CancellationToken cancellationToken
)

Parses and verifies a Firebase ID token.

A Firebase client app can identify itself to a trusted backend server by sending its Firebase ID Token (accessible via the getIdToken() API in the Firebase client SDK) with its requests. The backend server can then use this method to verify that the token is valid. This method ensures that the token is correctly signed, has not expired, and it was issued against the Firebase project associated with this FirebaseAuth instance.

If checkRevoked is set to true, this method performs an additional check to see if the ID token has been revoked since it was issued. This requires making an additional remote API call.

See Verify ID Tokens for code samples and detailed documentation.

Details
Exceptions
ArgumentException
If ID token argument is null or empty.
FirebaseAuthException
If the ID token fails to verify.
Parameters
idToken
A Firebase ID token string to parse and verify.
checkRevoked
A boolean indicating whether to check if the tokens were revoked.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a FirebaseToken representing the verified and decoded ID token.

Protected functions

IfNotDeleted< TResult >

TResult IfNotDeleted< TResult >(
  Func< TResult > func
)

IsRevokedAsync

async Task< bool > IsRevokedAsync(
  FirebaseToken token,
  CancellationToken cancellationToken
)