Stay organized with collections
Save and categorize content based on your preferences.
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.
import{getAuth,signInWithCustomToken}from"firebase/auth";constauth=getAuth();signInWithCustomToken(auth,token).then((userCredential)=>{// Signed inconstuser=userCredential.user;// ...}).catch((error)=>{consterrorCode=error.code;consterrorMessage=error.message;// ...});
firebase.auth().signInWithCustomToken(token).then((userCredential)=>{// Signed invaruser=userCredential.user;// ...}).catch((error)=>{varerrorCode=error.code;varerrorMessage=error.message;// ...});
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThis guide details how to use Identity Platform for user sign-in with a custom authentication system, leveraging custom signed tokens generated by your authentication server.\u003c/p\u003e\n"],["\u003cp\u003eBefore implementing custom authentication, you should consider migrating users if Identity Platform natively supports your app's sign-in method.\u003c/p\u003e\n"],["\u003cp\u003eThe sign-in process involves collecting user credentials, sending them to your server for validation, receiving a custom JWT, and then using \u003ccode\u003esignInWithCustomToken()\u003c/code\u003e to authenticate the user with Identity Platform.\u003c/p\u003e\n"],["\u003cp\u003eTo begin, you will need to install the client SDK and ensure that your server can accept user credentials and mint custom tokens.\u003c/p\u003e\n"],["\u003cp\u003eOnce the user is signed in, you can then configure custom claims and integrate Identity Platform using the REST API.\u003c/p\u003e\n"]]],[],null,["# Signing in users with a custom authentication system\n====================================================\n\nThis 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.\n| **Note:** If your app uses a sign-in method that Identity Platform supports (such as email and password), consider [migrating users](/identity-platform/docs/migrating-users) instead of implementing custom authentication.\n\nBefore you begin\n----------------\n\n- [Install the client SDK](/identity-platform/docs/quickstart-email-password).\n\n- Configure your server to accept user credentials and\n [mint custom tokens](/identity-platform/docs/admin/create-custom-tokens).\n\nSigning in users\n----------------\n\n1. Collect sign-in credentials from the user.\n\n2. Send the credentials to your server. Your server validates the request, and\n returns a custom JWT.\n\n3. Pass the JWT to\n [`signInWithCustomToken()`](/identity-platform/docs/reference/rest/v1/accounts/signInWithCustomToken)\n to authenticate the user with Identity Platform:\n\n ### Web version 9\n\n ```javascript\n import { getAuth, signInWithCustomToken } from \"firebase/auth\";\n\n const auth = getAuth();\n signInWithCustomToken(auth, token)\n .then((userCredential) =\u003e {\n // Signed in\n const user = userCredential.user;\n // ...\n })\n .catch((error) =\u003e {\n const errorCode = error.code;\n const errorMessage = error.message;\n // ...\n });https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/snippets/auth-next/custom/auth_sign_in_custom.js#L8-L21\n ```\n\n ### Web version 8\n\n ```javascript\n firebase.auth().signInWithCustomToken(token)\n .then((userCredential) =\u003e {\n // Signed in\n var user = userCredential.user;\n // ...\n })\n .catch((error) =\u003e {\n var errorCode = error.code;\n var errorMessage = error.message;\n // ...\n });https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/auth/custom.js#L10-L20\n ```\n\nWhat's next\n===========\n\n- [Configure custom claims](/identity-platform/docs/how-to-configure-custom-claims) on users.\n- [Use the REST API](/identity-platform/docs/use-rest-api) to integrate Identity Platform with other parts of your custom authentication system."]]