使用AWS Cognito进行react-native-google-signin

卢卡斯·博尔迪尼翁(Lucas Bordignon)

我正在开发一个本机应用程序,我想让我的用户能够使用Google登录。但是,当我向Google API发出请求时,它会返回WRONG SIGNIN Error: DEVELOPER_ERROR

我正在使用AWS Cognito,并希望将Google登录名与其集成。我看到了一些问题,据说这些问题会生成我的“ webClientId”的SHA-1蓝图,但是所有这些问题都使用firebase。在Cognito上,没有字段可添加各自的SHA-1蓝图。

我的代码如下:

  componentWillMount() {
        GoogleSignin.configure({
          webClientId: googleConfig.clientId
        });
    }

...

  googleSignIn() {
      GoogleSignin.signIn()
      .then((user) => {
        console.log(user);
        this.setState({user: user});
      })
      .catch((err) => {
        console.log('WRONG SIGNIN', err);
      })
      .done();
  }

...

<GoogleSigninButton
              style={{ height: 48 }}
              size={GoogleSigninButton.Size.Standard}
              color={GoogleSigninButton.Color.Light}
              onPress={this.googleSignIn.bind(this)}/> 

先谢谢您的帮助。

马特·D

这是配置不匹配。确保您的android / app / google-services.json是正确的。

您可能需要将SHA证书指纹添加到Firebase配置中。按照此帖子上的说明查找您的SHA1指纹:密钥库证书的SHA-1指纹然后,转到https://console.firebase.google.com/,选择您的应用程序,然后在“项目设置”(左上角的齿轮图标)下添加SHA1值->您的应用程序-> SHA证书指纹

如果要将配置对象中的webClientId传递给GoogleSignin.configure(),请确保其正确。您可以从Google Developer Console获取webClientId。它们列在“ OAuth 2.0客户端ID”下。

如果您以调试模式运行应用程序而不使用webClientId,或者您确定它是正确的,那么问题可能出在签名(SHA-1或SHA-256)不匹配。您需要将以下内容添加到android / app / build.gradle中:

signingConfigs {
    debug {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}

那是从这里

我还在github上找到了这个工作示例

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用带有自定义域的react-native-google-signin

AWS Cognito-放大:Auth.signIn,无论什么返回React Native中的NotAuthorizedException

react-native-google-signIn没有获得IDToken

在构建 React Native 项目时获取 react-native-google-signin:compileReleaseJavaWithJavac FAILED

Google SignIn拒绝使用Firebase

react-native-google-signin和android.support.v4.net不存在错误

使用 React Native + AWS Cognito 登录 FB

React Native:Auth.signIn() 返回什么?

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

无法解析模块 ./SignIn In React Native 应用程序

在React Native中使用Firebase进行Google登录

在iOS中使用Google SignIn后无法获取Authcode(Swift)

“ aws.cognito.signin.user.admin”范围在Amazon Cognito中是什么意思?

pod“ Google / SignIn”与pod“ GoogleSignIn”

当我在React Native中按下Signup按钮时,屏幕导航到Signin屏幕

如何同时使用Polymer的google-client-loader和google-signin?

iOS CocoaPod警告-使用Pod“ Google / SignIn”时,“ Google已被弃用”

使用 Cognito 进行 AWS 放大

使用AWS Cognito和React的仅限Facebook / Google的登录名(无用户名/密码)

将AWS Cognito与Google集成以及使用React自定义登录的步骤

使用React Hooks进行React Native onLayout

ITMS-90535无法使用最新的Google Signin SDK发布iOS应用

我可以在整个应用程序中使用Google SignIn令牌吗?

如何使用重定向模式(无弹出窗口)从 Google Signin 获取个人资料信息?

使用 Google SignIn 的 Firebase WebApp 仅适用于特定域和特定用户

使用 Unity 构建此 ios 项目,添加了 google signin SDK 4.0.1 框架,出现错误

如何确定用户之前是否已使用 google firebase signin 登录

如何使用Typescript在Angular 2中用Google实现SignIn

AWS Cognito + Google注册