This quickstart shows you how to use Identity Platform to sign in a user with an email and password.
Before you begin
-
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
-
In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.
Enable Identity Platform
Go to the Identity Platform Marketplace page in the Cloud Console.
Click Enable Identity Platform. The Identity Platform page appears in the Cloud Console.
Configure email sign-in
Go to the Identity Providers page in the Cloud Console.
Click Add A Provider.
Select Email/Password from the list of providers and enterprise federation standards.
Toggle the Enabled switch to On.
Click Save.
Create a user
Go to the Users page in the Cloud Console.
Click Add user.
Enter an email and password.
Click Save. The new user appears in the users list.
Sign the user in
Create a new file named
index.html
.Add two basic HTML containers:
<div>Identity Platform Quickstart</div> <div id="message">Loading...</div>
Initialize the Identity Platform Client SDK with your API key:
Go to the Identity Providers page in the Cloud Console.
Click Application setup details.
Copy the initialization code into
index.html
. It should look something like:<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase.js"></script> <script> // Initialize Identity Platform var config = { apiKey: "abcdefg123456", authDomain: "myproject.firebaseapp.com" }; firebase.initializeApp(config); </script>
Sign the user in by calling
signInWithEmailAndPassword()
, and then process the result with theonAuthStateChanged()
callback. In the example below, replaceemail
andpassword
with the values for the user you created earlier:<script> var email = "example@gmail.com"; var password = "hunter2"; firebase.auth().onAuthStateChanged(function(user) { if (user) { document.getElementById("message").innerHTML = "Welcome, " + user.email; } else { document.getElementById("message").innerHTML = "No user signed in."; } }); firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) { document.getElementById("message").innerHTML = error.message; }); </script>
Launch
index.html
in your web browser. A welcome message displaying your user's email appears.
Congratulations! You've signed your first user in with Identity Platform.
What's next
In a real app, your users would sign up using a dedicated registration page, and sign in by entering their emails and passwords. Identity Platform offers a pre-built authentication UI you can use for these pages, or you can build your own. You might also want to support additional sign-in methods, such as social providers (like Facebook or Google), phone numbers, OIDC, or SAML.
Learn more about how to:
- Sign in users with JavaScript, Android, iOS, C++, or Unity.
- Sign in users with OIDC or SAML.
- Migrate users from your existing app to Identity Platform.