Signing in users with a custom authentication system
This document shows you how to use Identity Platform to sign in users with a custom authentication system. In custom authentication, you use an authentication server to produce custom signed tokens when a user successfully signs in. Your app receives this token and uses it to authenticate with Identity Platform.
Before you begin
Configure your server to accept user credentials and mint custom tokens.
Signing in users
Collect sign-in credentials from the user.
Send the credentials to your server. Your server validates the request, and returns a custom JWT.
Pass the JWT to
signInWithCustomToken()
to authenticate the user with Identity Platform:Web version 9
import { getAuth, signInWithCustomToken } from "firebase/auth"; const auth = getAuth(); signInWithCustomToken(auth, token) .then((userCredential) => { // Signed in const user = userCredential.user; // ... }) .catch((error) => { const errorCode = error.code; const errorMessage = error.message; // ... });
Web version 8
firebase.auth().signInWithCustomToken(token) .then((userCredential) => { // Signed in var user = userCredential.user; // ... }) .catch((error) => { var errorCode = error.code; var errorMessage = error.message; // ... });
What's next
- Configure custom claims on users.
- Use the REST API to integrate Identity Platform with other parts of your custom authentication system.