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

Signing in users

  1. Collect sign-in credentials from the user.

  2. Send the credentials to your server. Your server validates the request, and returns a custom JWT.

  3. 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