FirebaseAdmin.Auth.FirebaseAuth

This is the entry point to all server-side Firebase Authentication operations.

Summary

You can get an instance of this class via FirebaseAuth.DefaultInstance.

Inheritance

Inherits from: FirebaseAdmin.Auth.AbstractFirebaseAuth

Properties

DefaultInstance
static FirebaseAuth
Gets the auth instance associated with the default Firebase app.

Public attributes

TenantManager => this.IfNotDeleted(() => this.tenantManager.Value)
Gets the TenantManager instance associated with the current project.

Public static functions

GetAuth(FirebaseApp app)
Returns the auth instance for the specified app.

Public functions

CreateSessionCookieAsync(string idToken, SessionCookieOptions options)
async Task< string >
Creates a new Firebase session cookie from the given ID token and options.
CreateSessionCookieAsync(string idToken, SessionCookieOptions options, CancellationToken cancellationToken)
async Task< string >
Creates a new Firebase session cookie from the given ID token and options.
VerifySessionCookieAsync(string sessionCookie)
async Task< FirebaseToken >
Parses and verifies a Firebase session cookie.
VerifySessionCookieAsync(string sessionCookie, CancellationToken cancellationToken)
async Task< FirebaseToken >
Parses and verifies a Firebase session cookie.
VerifySessionCookieAsync(string sessionCookie, bool checkRevoked)
async Task< FirebaseToken >
Parses and verifies a Firebase session cookie.
VerifySessionCookieAsync(string sessionCookie, bool checkRevoked, CancellationToken cancellationToken)
async Task< FirebaseToken >
Parses and verifies a Firebase session cookie.

Properties

DefaultInstance

static FirebaseAuth DefaultInstance

Gets the auth instance associated with the default Firebase app.

This property is null if the default app doesn't yet exist.

Public attributes

TenantManager

TenantManager TenantManager => this.IfNotDeleted(() => this.tenantManager.Value)

Gets the TenantManager instance associated with the current project.

Public static functions

GetAuth

FirebaseAuth GetAuth(
  FirebaseApp app
)

Returns the auth instance for the specified app.

Details
Exceptions
System.ArgumentNullException
If the app argument is null.
Parameters
app
An app instance.
Returns
The FirebaseAuth instance associated with the specified app.

Public functions

CreateSessionCookieAsync

async Task< string > CreateSessionCookieAsync(
  string idToken,
  SessionCookieOptions options
)

Creates a new Firebase session cookie from the given ID token and options.

The returned JWT can be set as a server-side session cookie with a custom cookie policy.

Details
Exceptions
FirebaseAuthException
If an error occurs while creating the cookie.
Parameters
idToken
The Firebase ID token to exchange for a session cookie.
options
Additional options required to create the cookie.
Returns
A task that completes with the Firebase session cookie.

CreateSessionCookieAsync

async Task< string > CreateSessionCookieAsync(
  string idToken,
  SessionCookieOptions options,
  CancellationToken cancellationToken
)

Creates a new Firebase session cookie from the given ID token and options.

The returned JWT can be set as a server-side session cookie with a custom cookie policy.

Details
Exceptions
FirebaseAuthException
If an error occurs while creating the cookie.
Parameters
idToken
The Firebase ID token to exchange for a session cookie.
options
Additional options required to create the cookie.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with the Firebase session cookie.

VerifySessionCookieAsync

async Task< FirebaseToken > VerifySessionCookieAsync(
  string sessionCookie
)

Parses and verifies a Firebase session cookie.

See Manage Session Cookies for code samples and detailed documentation.

Details
Exceptions
ArgumentException
If the session cookie is null or empty.
FirebaseAuthException
If the session cookie is invalid.
Parameters
sessionCookie
A Firebase session cookie string to verify and parse.
Returns
A task that completes with a FirebaseToken representing the verified and decoded session cookie.

VerifySessionCookieAsync

async Task< FirebaseToken > VerifySessionCookieAsync(
  string sessionCookie,
  CancellationToken cancellationToken
)

Parses and verifies a Firebase session cookie.

See Manage Session Cookies for code samples and detailed documentation.

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

VerifySessionCookieAsync

async Task< FirebaseToken > VerifySessionCookieAsync(
  string sessionCookie,
  bool checkRevoked
)

Parses and verifies a Firebase session cookie.

See Manage Session Cookies for code samples and detailed documentation.

Details
Exceptions
ArgumentException
If the session cookie is null or empty.
FirebaseAuthException
If the session cookie is invalid.
Parameters
sessionCookie
A Firebase session cookie string to verify and parse.
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 session cookie.

VerifySessionCookieAsync

async Task< FirebaseToken > VerifySessionCookieAsync(
  string sessionCookie,
  bool checkRevoked,
  CancellationToken cancellationToken
)

Parses and verifies a Firebase session cookie.

See Manage Session Cookies for code samples and detailed documentation.

Details
Exceptions
ArgumentException
If the session cookie is null or empty.
FirebaseAuthException
If the session cookie is invalid.
Parameters
sessionCookie
A Firebase session cookie string to verify and parse.
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 session cookie.