首页 > 解决方案 > Firebase 对列入白名单的链接说“域未列入白名单”

问题描述

我正忙于使用电子邮件魔术链接设置 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 身份验证吗?如果是这样,我在控制台的哪个位置将域列入白名单,因为我找不到它。

标签: androidfirebasefirebase-authentication

解决方案


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

在此页面上进一步向下滚动


推荐阅读