谷歌登录不允许使用 Firebase 身份验证/操作

时间:2021-01-06 14:31:11

标签: android firebase react-native firebase-authentication

在 React Native 应用程序中

我正在尝试使用 firebase 对 google 登录进行身份验证。

在我的 firebase 控制台 > 身份验证 > 登录方法中,我启用了 google 并保存了它。 Click here 查看图片。

但是当我尝试登录时,它会向我抛出一个错误,说 auth/operation-not-allowed

import Auth, { firebase } from '@react-native-firebase/auth';
import { GoogleSignin } from "@react-native-community/google-signin";

const {idToken} = await GoogleSignin.signIn();
const googleCredential = Auth.GoogleAuthProvider.credential(idToken);
return await Auth().signInWithCredential(credential);

我有类似的错误

Error: [auth/operation-not-allowed] The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section. [ The identity provider configuration is disabled. ]
NativeFirebaseError: [auth/operation-not-allowed] The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section. [ The identity provider configuration is disabled. ]
    at FirebaseAuthModule.signInWithCredential (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:154406:28)
    at signInWithCredential$ (http://10.0.2.2:8081/src/Utils/Auth.bundle?platform=android&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:84:68)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:24976:19)
    at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25149:24)
    at Generator.next (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25019:23)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:24976:19)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25049:22)
    at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25079:13
    at tryCallTwo (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27065:7)

1 个答案:

答案 0 :(得分:0)

您似乎尚未在 Firebase 控制台中启用 Google 登录方法。要解决此问题,请执行以下操作:

  1. 进入 Firebase 控制台 (https://console.firebase.google.com/)。
  2. 选择您的项目。
  3. 在屏幕右侧,您会看到一个面板,点击显示“身份验证”的位置。
  4. 进入身份验证菜单后,转到登录方法。
  5. 然后在出现在标题下方的列表中查找 google 访问提供商并点击它。
  6. 然后点击启用按钮。

您可能需要配置一个安全的项目 ID(您会在启用按钮下方看到一个下拉菜单)。您需要做的是,从您的项目中输入 android 和/或 ios 客户端 ID,然后点击保存。这将告诉 firebase 使用该客户端处理登录操作是安全的。