javascript - Google SignIn SDK 因抛出错误而失败,发生不可恢复的登录失败 - 捕获错误 : React Native

标签 javascript android reactjs react-native google-signin

我一直在尝试将 Social 登录集成到我的 React Native 项目中,在该项目中我能够成功登录 Facebook,但无法登录 Google。 react-native-google-signin 库用于谷歌。

我用过的代码。

componentDidMount() {
GoogleSignin.hasPlayServices({ autoResolve: true }).then(() => {
// play services are available. can now configure library
}).catch((err) => {

console.log("Play services error", err.code, err.message);
})
GoogleSignin.configure({
scopes: ["https://www.googleapis.com/auth/drive.readonly"], // what API you want to access on behalf of the user, default is email and profile
// iosClientId: <FROM DEVELOPER CONSOLE>, // only for iOS
webClientId: "xxx", // client ID of type WEB for your server (needed to verify user ID and offline access)
// offlineAccess: true // if you want to access Google API on behalf of the user FROM YOUR SERVER
//hostedDomain: '' // specifies a hosted domain restriction
//forceConsentPrompt: true // [Android] if you want to show the authorization prompt at each login
//accountName: '' // [Android] specifies an account name on the device that should be used
})
.then(() => {
// you can now call currentUserAsync()
});
    _signIn = async () => {

        try {

            await GoogleSignin.hasPlayServices(

              )

          const userInfo = await GoogleSignin.signIn();
          console.log('User Info --> ', userInfo);
          this.setState({ userInfo });
        } catch (error) {

          console.log('Message', error.message);
          if (error.code ===  statusCodes.SIGN_IN_CANCELLED) {
            console.log('User Cancelled the Login Flow');
          } else if (error.code === statusCodes.IN_PROGRESS) {
            console.log('Signing In');
          } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
            console.log('Play Services Not Available or Outdated');
          } else {
            console.log('Some Other Error Happened');
          }
        }
      };

错误响应:

Message: A non-recoverable sign in failure occurred -catch error

最佳答案

我知道,我很晚才回答这个问题。我刚遇到同样的问题,花了将近 4-5 个小时来解决这个问题。 我找到的解决方案: “当我在 Firebase 上添加支持电子邮件后它开始工作” 我认为这不是应用程序或配置问题。这可能是一个应该报告的 firebase 问题,但在文档中无处可寻。

Screenshot for Firebase settings

关于javascript - Google SignIn SDK 因抛出错误而失败,发生不可恢复的登录失败 - 捕获错误 : React Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53816227/

相关文章:

Javascript 停止并播放不同的声音

android - 将应用程序移动到手机

android - 如何使用 intellij idea 调试已签名的应用程序?

javascript - Redux-reducer 已成功更新,但连接组件的 componentWillReceiveProps 仍显示旧状态

javascript - 是否可以反向播放 HTML5 视频?

javascript - 使用 "forEach "的嵌套循环迭代 meteor 中的集合

javascript - 在 Canvas 上绘制多个矩形

android - 使用 ffmpeg 确定歌曲的节奏

reactjs - 在 React Native 中合并/组合两个或多个不同的样式表组件?

node.js - 我们如何使用访问 token 来授权我们的rest api?