Reputation: 341
I am trying to display the name of my website on AuthO popups. No issues with Facebook, Twitter or GitHub auth. But Google's popup keep showing 'Sign in to continue to projectName.firebase.com' Instead of 'example.com'. I mean it shows firebase's default domain instead of custom one.
Even if I change display name to some custom name in console.developers.google.com
.
Upvotes: 23
Views: 6907
Reputation: 329
For me it was a bit confusing trying to collect the steps from multiple answers and responses, so I will sum up what worked for me fast & easy.
My Stack:
Continuing to the steps:
Choose a domain to use for the Google popup, for the sake of the example I will simply use auth.example.com
. This domain will be shown for the user as 'example.com` instead of the Firebase project default domain. Also, this domain job is to redirect the request to Firebase auth URL.
Activate Firebase hosting (even if you are not using it for hosting your application)
Add & verify domain in the Firebase Hosting:
In the Firebase hosting, press Add custom domain
, and enter the domain you
selected in step 1
(auth.example.com
)
Don't tick the redirect option and click continue
Now you need to verify ownership of the new custom domain and update your records based on the ones Firebase is requesting. Also, if you are using Cloudflare, make sure to disable the proxy in this step and then click verify(may take a few minutes).
Add your domain as one of the authorized redirect URIs.
APIs & Services
dashboard, linkCredentials
-> choose your client from the list under OAuth 2.0 Client IDs
Authorized redirect URIs
section add your domain with the schema: https://auth.example.com/__/auth/handler
and click saveAdd your domain to Firebase Authentication allowed domains.
Authentication
section and click Settings
Authorized Domains
and add your domain: auth.example.com
Once the custom domain certification is approved on the Firebase Hosting page update the CNAME to point at your Firebase app domain like this:
auth.example.com
-> example1234.firebaseapp.com
Update your code to support this new change. When setting up the firebaseApp, provide your new auth domain in the authDomain property like this:
import { initializeApp } from "firebase/app"; const firebaseApp = initializeApp({ apiKey: "", authDomain: "auth.example.com", projectId: "", storageBucket: "", messagingSenderId: "", appId:"" , measurementId:"" , });
Upvotes: 7
Reputation: 734
In the newest version of Firebase user guide they explain how to fix this, by pointing authDomain
initialization property to your domain, and making a few other preparations: https://firebase.google.com/docs/auth/web/google-signin#customizing-the-redirect-domain-for-google-sign-in
- Create a CNAME record for your custom domain that points to your project's subdomain on firebaseapp.com:
auth.custom.domain.com CNAME my-app-12345.firebaseapp.com
- Add your custom domain to the list of authorized domains in the Firebase console:
auth.custom.domain.com
.- In the Google developer console or OAuth setup page, whitelist the URL of the redirect page, which will be accessible on your custom domain: https://auth.custom.domain.com/__/auth/handler.
- When you initialize the JavaScript library, specify your custom domain with the
authDomain
field
Update: one important detail that's missing from the instructions is that the custom auth domain must be configured for Firebase Hosting (i.e. add it to the list of custom domains for Hosting on the Firebase Console). Otherwise you will get a certificate mismatch error as @AmritanshSinghal correctly points out.
Upvotes: 16
Reputation: 321
Ok, for those following these instructions and running into issues, I have two other pieces of advice.
- In the Google developer console or OAuth setup page, whitelist the URL of the redirect page, which will be accessible on your custom domain: https://auth.custom.domain.com/__/auth/handler.
This was really confusing to me. Here is where to do that.
Once you do all of this, you'll then get a CERT failure. Follow the instructions on this stackoverflow issue, wait a few hours, and everything will magically work!
Good luck!
Upvotes: 12