Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Procéder à la connexion des utilisateurs avec un système d'authentification personnalisé
Ce document explique comment utiliser Identity Platform pour connecter les utilisateurs avec un système d'authentification personnalisé. Dans l'authentification personnalisée, vous utilisez un serveur d'authentification pour générer des jetons signés personnalisés lorsqu'un utilisateur se connecte avec succès. Votre application reçoit ce jeton et l'utilise pour s'authentifier auprès d'Identity Platform.
Collectez les identifiants de connexion de l'utilisateur.
Envoyez les identifiants à votre serveur. Votre serveur valide la requête et renvoie un jeton JWT personnalisé.
Transmettez le jeton JWT à signInWithCustomToken() pour authentifier l'utilisateur avec Identity Platform :
Version Web 9
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;// ...});
Utilisez l'API REST pour intégrer Identity Platform à d'autres parties de votre système d'authentification personnalisée.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (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."]]