Manage Users in Firebase

Create a user

You create a new user in your Firebase project by calling theCreateUserWithEmailAndPasswordmethod or by signing in a user for the first time using a federated identityprovider, such asGoogle Sign-In orFacebook Login.

You can also create new password-authenticated users from the Authenticationsection of theFirebase console, on the Users page.

Get the currently signed-in user

The recommended way to get the current user is by setting a listener on theAuth object:

Firebase.Auth.FirebaseAuthauth;Firebase.Auth.FirebaseUseruser;// Handle initialization of the necessary firebase modules:voidInitializeFirebase(){Debug.Log("Setting up Firebase Auth");auth=Firebase.Auth.FirebaseAuth.DefaultInstance;auth.StateChanged+=AuthStateChanged;AuthStateChanged(this,null);}// Track state changes of the auth object.voidAuthStateChanged(objectsender,System.EventArgseventArgs){if(auth.CurrentUser!=user){boolsignedIn=user!=auth.CurrentUser &&auth.CurrentUser!=null;if(!signedIn &&user!=null){Debug.Log("Signed out "+user.UserId);}user=auth.CurrentUser;if(signedIn){Debug.Log("Signed in "+user.UserId);}}}// Handle removing subscription and reference to the Auth instance.// Automatically called by a Monobehaviour after Destroy is called on it.voidOnDestroy(){auth.StateChanged-=AuthStateChanged;auth=null;}

By using a listener, you ensure that the Auth object isn't in an intermediatestate—such as initialization—when you get the current user.

You can also get the currently signed-in user by callingCurrentUser. If auser isn't signed in,CurrentUser will return null. If a user is signed out,the user'sIsValid() will return false.

Note:CurrentUser might also return null because the auth object has notfinished initializing. If you use a listener to keep track of the user'ssign-in status, you don't need to handle this case.

Persist a user's credential

The user's credentials will be stored in the local keystore after a useris signed in. The local cache of user credentials can be deleted by signingthe user out. The keystore is platform specific:

Get a user's profile

To get a user's profile information, use the accessor methods of an instance ofFirebase.Auth.FirebaseUser. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;if(user!=null){stringname=user.DisplayName;stringemail=user.Email;System.Uriphoto_url=user.PhotoUrl;// 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.TokenAsync() instead.stringuid=user.UserId;}

Get a user's provider-specific profile information

To get the profile information retrieved from the sign-in providers linked to auser, use theProviderData method. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;if(user!=null){foreach(varprofileinuser.ProviderData){// Id of the provider (ex: google.com)stringproviderId=profile.ProviderId;// UID specific to the providerstringuid=profile.UserId;// Name, email address, and profile photo Urlstringname=profile.DisplayName;stringemail=profile.Email;System.UriphotoUrl=profile.PhotoUrl;}}

Update a user's profile

You can update a user's basic profile information—the user's display nameand profile photo URL—with theUpdateUserProfile method. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;if(user!=null){Firebase.Auth.UserProfileprofile=newFirebase.Auth.UserProfile{DisplayName="Jane Q. User",PhotoUrl=newSystem.Uri("https://example.com/jane-q-user/profile.jpg"),};user.UpdateUserProfileAsync(profile).ContinueWith(task=>{if(task.IsCanceled){Debug.LogError("UpdateUserProfileAsync was canceled.");return;}if(task.IsFaulted){Debug.LogError("UpdateUserProfileAsync encountered an error: "+task.Exception);return;}Debug.Log("User profile updated successfully.");});}

Set a user's email address

You can set a user's email address with theUpdateEmail method. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;if(user!=null){user.UpdateEmailAsync("user@example.com").ContinueWith(task=>{if(task.IsCanceled){Debug.LogError("UpdateEmailAsync was canceled.");return;}if(task.IsFaulted){Debug.LogError("UpdateEmailAsync encountered an error: "+task.Exception);return;}Debug.Log("User email updated successfully.");});}
Important: To set a user's email address, the user must have signed in recently.SeeRe-authenticate a user.

Send a user a verification email

You can send an address verification email to a user with theSendEmailVerification method. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;if(user!=null){user.SendEmailVerificationAsync().ContinueWith(task=>{if(task.IsCanceled){Debug.LogError("SendEmailVerificationAsync was canceled.");return;}if(task.IsFaulted){Debug.LogError("SendEmailVerificationAsync encountered an error: "+task.Exception);return;}Debug.Log("Email sent successfully.");});}

You can customize the email template that is used in Authentication section oftheFirebase console, on the Email Templates page.SeeEmail Templates inFirebase Help Center.

Set a user's password

You can set a user's password with theUpdatePassword method. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;stringnewPassword="SOME-SECURE-PASSWORD";if(user!=null){user.UpdatePasswordAsync(newPassword).ContinueWith(task=>{if(task.IsCanceled){Debug.LogError("UpdatePasswordAsync was canceled.");return;}if(task.IsFaulted){Debug.LogError("UpdatePasswordAsync encountered an error: "+task.Exception);return;}Debug.Log("Password updated successfully.");});}
Important: To set a user's password, the user must have signed in recently. SeeRe-authenticate a user.

Send a password reset email

You can send a password reset email to a user with theSendPasswordResetEmailmethod. For example:

stringemailAddress="user@example.com";if(user!=null){auth.SendPasswordResetEmailAsync(emailAddress).ContinueWith(task=>{if(task.IsCanceled){Debug.LogError("SendPasswordResetEmailAsync was canceled.");return;}if(task.IsFaulted){Debug.LogError("SendPasswordResetEmailAsync encountered an error: "+task.Exception);return;}Debug.Log("Password reset email sent successfully.");});}

You can customize the email template that is used in Authentication section oftheFirebase console, on the Email Templates page.SeeEmail Templates inFirebase Help Center.

You can also send password reset emails from theFirebase console.

Delete a user

You can delete a user account with theDelete method. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;if(user!=null){user.DeleteAsync().ContinueWith(task=>{if(task.IsCanceled){Debug.LogError("DeleteAsync was canceled.");return;}if(task.IsFaulted){Debug.LogError("DeleteAsync encountered an error: "+task.Exception);return;}Debug.Log("User deleted successfully.");});}
Important: To delete a user, the user must have signed in recently. SeeRe-authenticate a user.

You can also delete users from the Authentication section of theFirebase console, on the Users page.

Re-authenticate a user

Some security-sensitive actions—such asdeleting an account,setting a primary email address, andchanging a password—require that the user hasrecently signed in. If you perform one of these actions, and the user signed intoo long ago, the action fails.

When this happens, re-authenticate the user by getting new sign-in credentialsfrom the user and passing the credentials toReauthenticate. For example:

Firebase.Auth.FirebaseUseruser=auth.CurrentUser;// Get auth credentials from the user for re-authentication. The example below shows// email and password credentials but there are multiple possible providers,// such as GoogleAuthProvider or FacebookAuthProvider.Firebase.Auth.Credentialcredential=Firebase.Auth.EmailAuthProvider.GetCredential("user@example.com","password1234");if(user!=null){user.ReauthenticateAsync(credential).ContinueWith(task=>{if(task.IsCanceled){Debug.LogError("ReauthenticateAsync was canceled.");return;}if(task.IsFaulted){Debug.LogError("ReauthenticateAsync encountered an error: "+task.Exception);return;}Debug.Log("User reauthenticated successfully.");});}

Import user accounts

You can import user accounts from a file into your Firebase project by using theFirebase CLI'sauth:import command. For example:

firebaseauth:importusers.json--hash-algo=scrypt--rounds=8--mem-cost=14

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.