【问题标题】:Firebase says "Domain not whitelisted" for a link that is whitelistedFirebase 对列入白名单的链接说“域未列入白名单”
【发布时间】:2018-12-24 17:51:44
【问题描述】:

我正忙于使用电子邮件魔术链接设置 Firebase 身份验证并使用此处的指南:

https://firebase.google.com/docs/auth/android/email-link-auth

它说我需要将域列入白名单,但除了我创建的动态链接之外,我在控制台中找不到任何地方可以做到这一点。我尝试运行以下代码,但我得到了

[ UNAUTHORIZED_DOMAIN:域未被项目列入白名单]

    val actionCodeSettings = ActionCodeSettings.newBuilder()
            // URL you want to redirect back to. The domain (www.example.com) for this
            // URL must be whitelisted in the Firebase Console.
            .setUrl("https://myapphere.page.link/register") //I created this dynamic link in the firebase console
            .setHandleCodeInApp(true)
            .setAndroidPackageName(
                    "com.myapphere",
                    true, 
                    "1")
            .build()

    val auth = FirebaseAuth.getInstance()
    auth.sendSignInLinkToEmail(email, actionCodeSettings)
            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                    // Sign in success, update UI with the signed-in user's information
                } else {
                    // If sign in fails, display a message to the user.
                }
            }

我不应该使用动态链接进行 Firebase 身份验证吗?如果是这样,我在控制台的哪个位置将域列入白名单,因为我找不到它。

【问题讨论】:

    标签: android firebase firebase-authentication


    【解决方案1】:
    1. 转到 Firebase 控制台
    2. 单击身份验证菜单 > 登录方法选项卡
    3. 向下滚动到授权域
    4. 单击“添加域”按钮,添加您的域(带参数的网站域)并单击“添加”

    【讨论】:

    • 也许您可以多解释一下“域”的含义。它可以是 com.yourcompany.yourappname 之类的应用程序域,也可以是 yourcompanyappname.com 之类的网站域。对于较新的开发人员,这些信息可能很有用。在您的情况下,它可能是 setUrl 上的 myapphere.page.link,但最好提一下。
    • 我可以在授权域下使用 com.yourcompany.yourappname 作为域名吗?
    【解决方案2】:

    我遇到了同样的问题,原因是我在 Firebase 中配置的 SHA-1 密钥错误。

    【讨论】:

    • 你能说得更详细些吗?该密钥在哪里配置?你的配置有什么问题?
    【解决方案3】:

    更多详情: 当我尝试像这样sendSignInLinkToEmail 时会发生此问题

    firebase
      .auth()
      .sendSignInLinkToEmail('someone@example.com', {
        url: 'my.custom.domain',
        handleCodeInApp: true
    });
    

    如果您在 Firebase 托管中提供了默认域,那么在您添加自己的自定义域之前就可以了。

    这可以通过在身份验证 -> 登录方法 -> 授权域

    中将您的自定义域添加到 Authorized Domains 来解决

    【讨论】:

      【解决方案4】:

      为了克服这个错误,我必须做:

          const actionCodeSettings = {
          ¦ // URL you want to redirect back to. The domain (www.example.com) for this
          ¦ // URL must be in the authorized domains list in the Firebase Console.
          ¦ url: 'https://example.com',
          ¦ handleCodeInApp: true,
          };
      

      然后将example.comwww.example.com 添加到我的授权域。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-08
        • 2018-01-22
        • 2017-09-19
        相关资源
        最近更新 更多