且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更改用于Firebase身份验证的应用程序名称(用户看到的内容)

更新时间:2023-12-05 16:49:28

我向Firebase寻求支持,并得到以下答复. 斜体中的项目是我的补充.

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

-

嗨Jayen,

感谢您与我们联系.我很乐意为您提供帮助.

Thank you for reaching out. I'll be happy to assist you.

为了在OAuth同意屏幕中更新firebase-project-id.firebaseapp.com,您需要一个具有Firebase托管的自定义域(Firebase控制台>托管>连接域).这是因为 https://firebase-project-id.firebaseapp.com/__/auth/handler 由Firebase Hosting托管.您需要将自定义域指向firebase-project-id.firebaseapp.com.

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.

连接自定义域时,如果您不是将应用托管在Firebase上,请使用新的子域(例如app.yourdomain.com),并且不要重定向它. Firebase会提示您添加DNS条目并自动获取SSL证书.

将自定义域连接到Firebase项目后,您还应该按照以下步骤操作:

After connecting your custom domain to your Firebase project, you should also follow the steps below:

  1. 转到Firebase控制台>选择项目">身份验证">登录方法>"Facebook">在要完成设置,将此OAuth重定向URI添加到您的Facebook应用程序配置"下复制URL.

  1. 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.'

将项目ID替换为您的自定义域.它将类似于: https://yourdomain.com/__/auth/handler

Replace the project ID with your custom domain. It will look something like: https://yourdomain.com/__/auth/handler

然后确保在应用的配置中使用yourdomain.com作为authDomain而不是firebase-project-id.firebaseapp.com

Then ensure to use yourdomain.com as the authDomain in your app's configuration instead of firebase-project-id.firebaseapp.com

firebase.initializeApp({
    apiKey: ....,
    authDomain: 'yourdomain.com',
     ...
});

如果您还有其他疑问,请告诉我.

Let me know if you have any other questions regarding this.

此致

-

在我的情况下,yourdomain.com是我托管网站的位置,因此我在需要的地方使用了app.yourdomain.com.

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

  • Firebase托管URL
  • 处理程序网址: https://app.yourdomain.com/__/auth/handler
  • GCP凭据
    • OAuth 2.0客户端ID 下选择合适的一个.客户端ID将与您在代码中配置的Firebase匹配.
    • Firebase Hosting URL
    • handler url: https://app.yourdomain.com/__/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.