| java.lang.Object | |
| ↳ | com.google.firebase.auth.FirebaseAuth |
This class is the entry point for all server-side Firebase Authentication actions.
You can get an instance of FirebaseAuth via getInstance(FirebaseApp) and
then use it to perform a variety of authentication-related operations, including generating
custom tokens for use by client-side code, verifying Firebase ID Tokens received from clients, or
creating new FirebaseApp instances that are scoped to a particular authentication UID.
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Task<String> |
createCustomToken(String uid)
Creates a Firebase Custom Token associated with the given UID.
| ||||||||||
| Task<String> |
createCustomToken(String uid, Map<String, Object> developerClaims)
Creates a Firebase Custom Token associated with the given UID and additionally containing the
specified developerClaims.
| ||||||||||
| Task<UserRecord> |
createUser(UserRecord.CreateRequest request)
Creates a new user account with the attributes contained in the specified
UserRecord.CreateRequest. | ||||||||||
| Task<Void> |
deleteUser(String uid)
Deletes the user identified by the specified user ID.
| ||||||||||
| static FirebaseAuth |
getInstance()
Gets the FirebaseAuth instance for the default
FirebaseApp. | ||||||||||
| synchronized static FirebaseAuth |
getInstance(FirebaseApp app)
Gets an instance of FirebaseAuth for a specific
FirebaseApp. | ||||||||||
| Task<UserRecord> |
getUser(String uid)
Gets the user data corresponding to the specified user ID.
| ||||||||||
| Task<UserRecord> |
getUserByEmail(String email)
Gets the user data corresponding to the specified user email.
| ||||||||||
| Task<UserRecord> |
updateUser(UserRecord.UpdateRequest request)
Updates an existing user account with the attributes contained in the specified
UserRecord.UpdateRequest. | ||||||||||
| Task<FirebaseToken> |
verifyIdToken(String token)
Parses and verifies a Firebase ID Token.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Creates a Firebase Custom Token associated with the given UID. This token can then be provided back to a client application for use with the signInWithCustomToken authentication API.
| uid | The UID to store in the token. This identifies the user to other Firebase services (Firebase Database, Firebase Auth, etc.) |
|---|
Task which will complete successfully with the created Firebase Custom Token,
or unsuccessfully with the failure Exception.
Creates a Firebase Custom Token associated with the given UID and additionally containing the specified developerClaims. This token can then be provided back to a client application for use with the signInWithCustomToken authentication API.
| uid | The UID to store in the token. This identifies the user to other Firebase services (Realtime Database, Storage, etc.). Should be less than 128 characters. |
|---|---|
| developerClaims | Additional claims to be stored in the token (and made available to security rules in Database, Storage, etc.). These must be able to be serialized to JSON (e.g. contain only Maps, Arrays, Strings, Booleans, Numbers, etc.) |
Task which will complete successfully with the created Firebase Custom Token,
or unsuccessfully with the failure Exception.
Creates a new user account with the attributes contained in the specified
UserRecord.CreateRequest.
| request | A non-null UserRecord.CreateRequest instance. |
|---|
Task which will complete successfully with a UserRecord instance
corresponding to the newly created account. If an error occurs while creating the user
account, the task fails with a FirebaseAuthException.| NullPointerException | if the provided request is null. |
|---|
Deletes the user identified by the specified user ID.
| uid | A user ID string. |
|---|
Task which will complete successfully when the specified user account has
been deleted. If an error occurs while deleting the user account, the task fails with a
FirebaseAuthException.| IllegalArgumentException | If the user ID string is null or empty. |
|---|
Gets the FirebaseAuth instance for the default FirebaseApp.
FirebaseApp.
Gets an instance of FirebaseAuth for a specific FirebaseApp.
| app | The FirebaseApp to get a FirebaseAuth instance for. |
|---|
Gets the user data corresponding to the specified user ID.
| uid | A user ID string. |
|---|
Task which will complete successfully with a UserRecord instance.
If an error occurs while retrieving user data or if the specified user ID does not exist,
the task fails with a FirebaseAuthException.| IllegalArgumentException | If the user ID string is null or empty. |
|---|
Gets the user data corresponding to the specified user email.
| A user email address string. |
Task which will complete successfully with a UserRecord instance.
If an error occurs while retrieving user data or if the email address does not correspond
to a user, the task fails with a FirebaseAuthException.| IllegalArgumentException | If the email is null or empty. |
|---|
Updates an existing user account with the attributes contained in the specified
UserRecord.UpdateRequest.
| request | A non-null UserRecord.UpdateRequest instance. |
|---|
Task which will complete successfully with a UserRecord instance
corresponding to the updated user account. If an error occurs while updating the user
account, the task fails with a FirebaseAuthException.| NullPointerException | if the provided update request is null. |
|---|
Parses and verifies a Firebase ID Token.
A Firebase application can identify itself to a trusted backend server by sending its Firebase ID Token (accessible via the getToken API in the Firebase Authentication client) with its request.
The backend server can then use the verifyIdToken() method to verify the token is valid, meaning: the token is properly signed, has not expired, and it was issued for the project associated with this FirebaseAuth instance (which by default is extracted from your service account)
If the token is valid, the returned Task will complete successfully and provide a
parsed version of the token from which the UID and other claims in the token can be inspected.
If the token is invalid, the Task will fail with an exception indicating the failure.
| token | A Firebase ID Token to verify and parse. |
|---|
Task which will complete successfully with the parsed token, or
unsuccessfully with the failure Exception.