ChatGPT解决这个技术问题 Extra ChatGPT

How to change the app name for Firebase authentication (what the user sees)

Thanks to Firebase v 3.9.0, my social OAuth is working great in my ionic app. I have one little change I'd like to make. When prompted to login, it says "Sign in to continue to my-real-appname-12345f.firebaseapp.com."

How to I change that to something more user-friendly like, you know, the app's actually name.

To clarify, I am using Firebase to handle authentication for both Google and Facebook. The message is the same for both.

Have you found a solution?
@Sub6Resources Check my ans.
None of the solutions on this question work anymore. They used to, but the oauth consent screen no longer shows the public-facing name setting (aka "product name shown to users") and instead shows the authDomain url. The only correct answer now is to change the default authDomain.

S
Stephen Ostermiller

I asked Firebase support and got the following reply. Items in italics are my additions.

In order to update firebase-project-id.firebaseapp.com in the OAuth consent screen, you need a custom domain with Firebase Hosting (Firebase Console > Hosting > Connect Domain). This is because https://firebase-project-id.firebaseapp.com/__/auth/handler is hosted by Firebase Hosting. You need to point your custom domain to firebase-project-id.firebaseapp.com. When connecting the custom domain, if you are not hosting your app on Firebase, use a new subdomain (e.g. app.yourdomain.example) and do not redirect it. Firebase will prompt you to add an entry on your DNS server and take care of the SSL certificate automatically. After connecting your custom domain to your Firebase project, you should also follow the steps below: Go to the Firebase Console > Select Project > Authentication > Sign-in method > Facebook > Copy the URL under 'To complete setup, add this OAuth redirect URI to your Facebook app configuration.' It will look something like https://firebase-project-id.firebaseapp.com/__/auth/handler Replace the project ID with your custom domain. It will look something like: https://yourdomain.example/__/auth/handler Go to the GCP Console > Select project > API Manager > Credentials > Add the link in #2 to the 'Authorized redirect URIs' Then ensure to use yourdomain.example as the authDomain in your app's configuration instead of firebase-project-id.firebaseapp.com firebase.initializeApp({ apiKey: ...., authDomain: 'yourdomain.example', ... });

In my case, yourdomain.example is where I host my site, so I used app.yourdomain.example where I needed it.

Firebase Hosting URL

handler URL: https://app.yourdomain.example/__/auth/handler

GCP Credentials Choose the right one under OAuth 2.0 client IDs. The client ID will match the one you have configured Firebase with in your code.

Choose the right one under OAuth 2.0 client IDs. The client ID will match the one you have configured Firebase with in your code.

authDomain: "app.yourdomain.example"


Thanks Jayen! Always nice to have a K17 friend solve a problem for you :)
Step #3 now doesn't let you paste inside "Authorized domains" subdomains or paths, so it only accepted me "yourdomain.com", even if i create it as app.yourdomain.com on firebase and created TXT and A records for it. Hope it will work..
@m4tt did you try to paste with the keyboard or mouse? if i recall correctly, one worked and the other didn't.
What does Firebase will prompt you to add a DNS entry and take of the SSL certificate automatically. mean? Note: My domain is hosted on different provider
Firebase will prompt you to add a DNS entry means they will tell you to use your DNS provider to add an entry.
S
Stephen Ostermiller

This is what worked for me:

Change the Firebase configuration you set in your code to have authDomain: "insertyourdomainnamehere.example" Press on the "Sign In With Google" on your app and see the error you get due to this change. Follow directions of the error.

The error lead me to https://console.cloud.google.com/apis/credentials (Google Cloud Platform > APIs & Services > Credentials).

On that page, look at "OAuth 2.0 Client IDs" section. For me, there is only one record "Web client (auto created by Google Service)." Click the edit button on it. Look for "Authorized redirect URIs" section. In that section, add: https://insertyourdomainnamehere.example/__/auth/handler.

Then it should work! It should now say "Sign in to continue to yourdomain.example."


Worked for me aug 2020!
Nice! It works for me. I don't need to create a new OAuth 2.0 Client ID. Just used existing one that Google generated and update the auth handler there.
L
Linh Nguyen

For my case on web app with email sign in i just need to go into project settings on console, under general tab change Public-facing name and the %APP_NAME% in email got changed


d
doubleOrt

You should make these modifications in the Google API Console (https://console.cloud.google.com). Go there, find your project's credentials, click "OAuth consent screen" and then there is a textbox that says "Product name shown to users", change the current name to your app's name and click "Save".


Can you direct me to credentials? I've never used console.cloud.google.com and had no luck finding it. Also, does this apply to FB logins as well?
@WayneF.Kaskie Well, you login with the account that owns the credentials, from there it is just some simple UI, hover over some dropdowns, etc. And it doesn't apply to Facebook logins, just Google.
Unfortunately, I have no idea where this information is, and haven't been able to find it. I'm working in firebase and the link provided is for google cloud. I know they are related in some way, but I haven't found it yet. I haven't gone live with the project yet, so I'm still hoping that someone can answer soon!
Doesnt work if you're using Firebase for managing authentications. It still shows the old app name.
Keeping this answer for "historical" purposes only, apparently, it doesn't work for most cases.
S
Sub 6 Resources

I think I may have found why some people are able to change the display name and others are not. Check your Hosting tab. If you have something deployed, it is likely deployed to the same url that is listed on your sign-in page. Try adding your domain name on that page and see if that works.


What if I have nothing deployed?
You don't necessarily have to have anything deployed. Just adding a custom domain might fix the issue.
indeed it does. have to go through the getting started to get to the custom domain option. when adding a domain, don't add your current hosting and don't redirect.
e
ehed

This help page is fairly comprehensive – but one of the key things you have to do is change the authDomain parameter in your firebase.config() settings.

But what if you are using their "easier configuration" for firebase on the web where you just load /__/firebase/3.7.4/init.js without specifying the config? Since it's automatically handled, is there a way to modify just the authDomain part of the config?