Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 使用AWS Cognito响应本地google登录_Amazon Web Services_React Native_Google Signin - Fatal编程技术网

Amazon web services 使用AWS Cognito响应本地google登录

Amazon web services 使用AWS Cognito响应本地google登录,amazon-web-services,react-native,google-signin,Amazon Web Services,React Native,Google Signin,我正在开发一个react本地应用程序,我想让我的用户能够登录google。但是,当我向googleapi发出请求时,它返回错误的登录错误:DEVELOPER\u Error 我正在使用AWS Cognito,希望将Google登录与之集成。我看到一些问题,说生成我的“webClientId”的SHA-1蓝图,但它们都使用firebase。在Cognito上,没有字段添加相应的SHA-1蓝图 我的代码如下: componentWillMount() { GoogleSignin

我正在开发一个react本地应用程序,我想让我的用户能够登录google。但是,当我向googleapi发出请求时,它返回
错误的登录错误:DEVELOPER\u 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)}/> 
componentWillMount(){
谷歌签名({
webClientId:googleConfig.clientId
});
}
...
谷歌签名{
谷歌签名
。然后((用户)=>{
console.log(用户);
this.setState({user:user});
})
.catch((错误)=>{
console.log('错误登录',错误);
})
.完成();
}
...
提前谢谢你的帮助

  • 转到AWS控制台>IAM>身份提供程序>创建提供程序>提供程序类型=OpenID连接>提供程序URL=>访问群体=“您在Google开发者控制台中创建的Google客户端ID”
  • 转到AWS控制台>Cognito>联合身份池。选择您的标识池,转到“编辑标识池”,然后导航到OpenID选项卡。你应该看到一个标题为“accounts.google.com”的复选框,选中它
  • 在代码中,当您构建用于调用
    GoogleAuthUtil.GetTokenGoogleAuthUtil.GetToken(this,googleAccount,scopes)
    的作用域字符串时,请使用在Google开发者控制台中生成的“Google WebApp客户端ID”。这就是
    scopes=“受众:服务器:客户端\u id:”+“webClientId”
  • 这是配置不匹配。确保您的 android/app/google-services.json是正确的

    您可能需要将SHA证书指纹添加到Firebase 配置。按照上的说明查找您的SHA1指纹 本帖: . 然后,转到,选择你的应用程序,然后 在项目设置下添加SHA1值(上方的齿轮图标 左)->您的应用->SHA证书指纹

    如果要将配置对象中的webClientId传递给 configure()确保它是正确的。你可以得到你的 来自谷歌开发者控制台的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上找到了它。

    您看过这个示例(react native cognito登录示例)了吗?它似乎涵盖了所有基础: