The entry point of the Firebase Authentication SDK.
object, which contains information about the signed-in user.
Public methodspublic void addAuthStateListener(@NonNull FirebaseAuth.AuthStateListener listener)
Registers a listener to changes in the user authentication state. There can be more than one listener registered at the same time for one or more FirebaseAuth
instances.
The listeners call back in the UI thread, on the following events:
It is a recommended practice to always listen to sign-out events, as you may want to prompt the user to sign in again and maybe restrict the information or actions they have access to.
Use removeAuthStateListener
to unregister a listener.
See addIdTokenListener
if you want to listen to token refreshes.
See Also: AuthStateListener
public void addIdTokenListener(@NonNull FirebaseAuth.IdTokenListener listener)
Registers a listener to changes in the token authentication state. There can be more than one listener registered at the same time for one or more FirebaseAuth
instances.
The listeners call back in the UI thread, on the following events:
It is a recommended practice to always listen to sign-out events, as you may want to prompt the user to sign in again and maybe restrict the information or actions they have access to.
Use removeIdTokenListener
to unregister a listener.
See addAuthStateListener
if you do not want to listen to token refreshes.
See Also: IdTokenListener
@Keep
public static @NonNull FirebaseAuth getInstance()
Returns an instance of this class corresponding to the default FirebaseApp
instance.
Note: Firebase Authentication does not currently support Android Direct Boot.
For Applications that use Direct Boot, check if android.content.Context.isDeviceProtectedStorage
is false
before you call FirebaseAuth.getInstance()
.
@Keep
public static @NonNull FirebaseAuth getInstance(@NonNull FirebaseApp firebaseApp)
Returns an instance of this class corresponding to the given FirebaseApp
instance.
Note: Firebase Authentication does not currently support Android Direct Boot.
For Applications that use Direct Boot, check if android.content.Context.isDeviceProtectedStorage
is false
before you call FirebaseAuth.getInstance(firebaseApp)
.
public @Nullable Task<AuthResult> getPendingAuthResult()
Returns a Task
wrapping an AuthResult
. This will return a non-null value if your app launches a web sign-in flow and the OS cleans up your hosting Activity
while in the background (likely due to a low-memory event). The returned result is the value that startActivityForSignInWithProvider
would have returned, which includes any Exceptions thrown. Otherwise, returns null.
This method will only return a non-null result for a sign-in once. A non-null value will only be present for suitably recent sign-ins to help prevent false positive sign-ins.
initializeRecaptchaConfigpublic @NonNull Task<Void> initializeRecaptchaConfig()
Initializes the reCAPTCHA Enterprise client proactively to enhance reCAPTCHA signal collection and to complete reCAPTCHA-protected flows in a single attempt.
Exceptions
FirebaseAuthException
thrown on initialization failures. Common reasons are:
public void setCustomAuthDomain(@NonNull String domain)
Sets the custom auth domain that is used to handle all sign-in redirects. End-users will see this domain when signing in.
The domain must be allowlisted in the Firebase Console. If the domain contains a scheme ( https://
or http://
) or trailing slashes, they will be stripped off.
public void setLanguageCode(@NonNull String languageCode)
Sets the user-facing language code for auth operations that can be internationalized, such as sendEmailVerification
. This language code should follow the conventions defined by the IETF in BCP47.
public void setTenantId(@NonNull String tenantId)
Sets the Tenant ID to be passed on all future sign-in/sign-up operations and sign in or sign up users to the specified project as identified by the tenant. If you change this field, future sign-in/sign-ups will contain the new value.
This is set to null as default and users are signed into the agent project.
Note: this is different from what the current user's Tenant ID is; you can change this instance's Tenant ID without affecting the current user.
public @NonNull Task<AuthResult> signInAnonymously()
Signs in the user anonymously without requiring any credential.
This method creates a new account in your Firebase Authentication system, except in the case where there was already an anonymous user signed in into this app. Access the signed-in user with getCurrentUser
.
Upon successful completion, this operation triggers an onIdTokenChanged
event in all registered s and an onAuthStateChanged
event in all registered AuthStateListener
s.
Anonymous users do not require any credential, and are useful in situations where you want to persist information about your users before asking them to sign in. For example, they may be useful when implementing a signed-out shopping cart in an e-commerce application.
Due to the unauthenticated nature of this kind of user, they are not transferrable across devices. In order to allow your app's users to keep their information, ask them to provide some other authentication credentials, and link them to the current user with linkWithCredential
.
Important: you must enable Anonymous accounts in the Firebase console before being able to use them.
signInWithEmailAndPassword
createUserWithEmailAndPassword
signInWithCredential
signInWithCustomToken
public void useAppLanguage()
Sets the user-facing language code to be the default app language.
public void useEmulator(@NonNull String host, int port)
Modifies this FirebaseAuth instance to communicate with the Firebase Authentication emulator.
Note: this must be called before this instance has been used to do any operations.
Parameters@NonNull String host
the emulator host (e.g. 10.0.2.2)
int port
the emulator port (e.g. 8080)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4