Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Memproses login pengguna dengan sistem autentikasi kustom
Dokumen ini menunjukkan cara menggunakan Identity Platform untuk memproses login pengguna dengan sistem autentikasi kustom. Dalam autentikasi kustom, Anda menggunakan server autentikasi untuk menghasilkan token bertanda tangan kustom saat pengguna berhasil login. Aplikasi Anda akan menerima token ini dan menggunakannya untuk melakukan autentikasi dengan Identity Platform.
Konfigurasikan server Anda untuk menerima kredensial pengguna dan
membuat token kustom.
Pengguna sedang login
Mengumpulkan kredensial login dari pengguna.
Kirim kredensial ke server Anda. Server Anda memvalidasi permintaan, dan
menampilkan JWT kustom.
Teruskan JWT ke signInWithCustomToken() untuk mengautentikasi pengguna dengan Identity Platform:
Web versi 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;// ...});
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-09 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\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- [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\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- [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."]]