Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Visualizzazione di un dominio personalizzato durante l'accesso
Questo documento spiega come personalizzare l'handler di autenticazione di Identity Platform in modo che gli utenti vedano il tuo dominio quando accedono.
Informazioni sul gestore di autenticazione predefinito
Quando attivi Identity Platform per il tuo progetto, viene creato automaticamente un sottodominio unico basato su Firebase Hosting.
Il dominio ha il formato https://[PROJECT-ID].firebaseapp.com.
Per impostazione predefinita, Identity Platform utilizza questo dominio per gestire tutti i reindirizzamenti di accesso OAuth, OIDC e SAML.
L'utilizzo del dominio predefinito offre diversi vantaggi:
Configurazione più semplice
Utilizzare più domini con gli stessi provider federati
Condividere un unico URL di callback su diversi servizi e domini
Funziona con i fornitori che supportano un solo URL di callback per app
Lo svantaggio dell'handler predefinito è che gli utenti vedranno brevemente l'URLhttps://[PROJECT-ID].firebaseapp.com al momento dell'accesso.
Personalizzazione del gestore dell'autenticazione
Per eseguire l'override del gestore predefinito e fornire il tuo:
Collegare il progetto a un dominio personalizzato.
Dovrai completare questi passaggi utilizzando la Console Firebase. L'utilizzo della CLI Google Cloud o della Google Cloud console non è supportato.
Aggiungi il dominio personalizzato all'elenco dei domini autorizzati.
Aggiorna l'URL di callback con il tuo provider di identità per utilizzare il tuo dominio personalizzato anziché quello predefinito. Ad esempio, cambia
https://myproject.firebaseapp.com/__/auth/handler in
https://auth.mycustomdomain.com/__/auth/handler.
Fai clic su Salva.
Aggiornamento della configurazione dell'SDK client
Web
In genere, puoi copiare il codice di inizializzazione per l'SDK client dalla
Google Cloud console. Se personalizzi il gestore dell'autenticazione, dovrai aggiornare il campo authDomain con il tuo dominio personalizzato:
Versione web 9
import{initializeApp}from"firebase/app";constfirebaseConfig={apiKey:"...",// By default, authDomain is '[YOUR_APP].firebaseapp.com'.// You may replace it with a custom domain.authDomain:'[YOUR_CUSTOM_DOMAIN]'};constfirebaseApp=initializeApp(firebaseConfig);
firebase.initializeApp({apiKey:'...',// By default, authDomain is '[YOUR_APP].firebaseapp.com'.// You may replace it with a custom domain.authDomain:'[YOUR_CUSTOM_DOMAIN]'});
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis guide explains how to customize the Identity Platform authentication handler to display your own domain during sign-in instead of the default \u003ccode\u003e[PROJECT-ID].firebaseapp.com\u003c/code\u003e domain.\u003c/p\u003e\n"],["\u003cp\u003eUsing the default domain provides benefits like easier setup and compatibility with providers that only allow one callback URL per app, but it briefly shows the \u003ccode\u003efirebaseapp.com\u003c/code\u003e URL to users.\u003c/p\u003e\n"],["\u003cp\u003eTo customize the handler, you must connect your project to a custom domain, add the custom domain to the list of Authorized Domains, and update the Callback URL with your identity provider to use the new custom domain.\u003c/p\u003e\n"],["\u003cp\u003eAfter customizing the handler, update the \u003ccode\u003eauthDomain\u003c/code\u003e field in your client SDK configuration (Web, Android, iOS) to your custom domain to ensure proper functionality.\u003c/p\u003e\n"],["\u003cp\u003eConfiguring your custom authentication handler is only available through the Firebase Console, and not through Google Cloud CLI or the Google Cloud console.\u003c/p\u003e\n"]]],[],null,["# Showing a custom domain during sign in\n======================================\n\nThis document shows you how to customize the Identity Platform authentication\nhandler so users see your domain when signing in.\n\nUnderstanding the default authentication handler\n------------------------------------------------\n\nWhen you enable Identity Platform for your project, a unique subdomain\npowered by Firebase Hosting is created automatically.\nThe domain takes the form of `https://[PROJECT-ID].firebaseapp.com`.\nBy default, Identity Platform uses this domain to handle all OAuth, OIDC,\nand SAML sign-in redirects.\n\nUsing the default domain has several benefits:\n\n- Easier setup\n\n- Use multiple domains with the same federated providers\n\n- Share a single callback URL across different services and domains\n\n- Works with providers that only support one callback URL per app\n\nThe downside of the default handler is users will briefly see the\n`https://[PROJECT-ID].firebaseapp.com` URL when signing in.\n\nCustomizing the authentication handler\n--------------------------------------\n\nTo override the default handler and provide your own:\n\n1. [Connect your project to a custom domain](https://firebase.google.com/docs/hosting/custom-domain).\n You'll need to complete these steps using the Firebase Console; using\n the Google Cloud CLI or the Google Cloud console is not\n supported.\n\n2. Go to the **Identity Providers** page in the Google Cloud console, and\n select your SAML provider.\n [Go to the Identity Providers page](https://console.cloud.google.com/customer-identity/providers) \n\n3. Add the custom domain to the list of **Authorized Domains**.\n\n4. Update the **Callback URL** with your identity provider to use your custom\n domain instead of the default domain. For example, change\n `https://myproject.firebaseapp.com/__/auth/handler` to\n `https://auth.mycustomdomain.com/__/auth/handler`.\n\n5. Click **Save**.\n\nUpdating your client SDK configuration\n--------------------------------------\n\n### Web\n\nNormally, you can copy the initialization code for the client SDK from the\nGoogle Cloud console. If you customize the authentication handler, you'll\nneed to update the `authDomain` field to your custom domain: \n\n### Web version 9\n\n```javascript\nimport { initializeApp } from \"firebase/app\";\n\nconst firebaseConfig = {\n apiKey: \"...\",\n // By default, authDomain is '[YOUR_APP].firebaseapp.com'.\n // You may replace it with a custom domain.\n authDomain: '[YOUR_CUSTOM_DOMAIN]'\n};\nconst firebaseApp = initializeApp(firebaseConfig);https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/snippets/auth-next/index/auth_init_custom_domain.js#L8-L16\n```\n\n### Web version 8\n\n```javascript\nfirebase.initializeApp({\n apiKey: '...',\n // By default, authDomain is '[YOUR_APP].firebaseapp.com'.\n // You may replace it with a custom domain.\n authDomain: '[YOUR_CUSTOM_DOMAIN]'\n});https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/auth/index.js#L107-L112\n```\n\n### Android and iOS\n\nTo customize the authentication handler, use the following code: \n\n### Java\n\n FirebaseAuth.getInstance().setCustomAuthDomain(\"[YOUR_CUSTOM_DOMAIN]\");\n\n### Kotlin+KTX\n\n Firebase.auth.setCustomAuthDomain(\"[YOUR_CUSTOM_DOMAIN]\")\n\n### Swift\n\n let auth = Auth.auth()\n auth.customAuthDomain = \"[YOUR_CUSTOM_DOMAIN]\"\n\n### Objective-C\n\n FIRAuth *auth = [FIRAuth auth];\n auth.customAuthDomain(\"[YOUR_CUSTOM_DOMAIN]\");"]]