我正在开发一个 react-native 应用程序,我想让我的用户能够使用 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)}/>
在此先感谢您的帮助。
最佳答案
This is configuration mismatch. Make sure that your android/app/google-services.json is correct.
You may need to add your SHA certificate fingerprint to your Firebase config. Find your SHA1 fingerprint by following the instructions on this post: SHA-1 fingerprint of keystore certificate. Then, go to https://console.firebase.google.com/, select your app, and add the SHA1 value under Project Settings (gear icon in the upper left) -> Your Apps -> SHA certificate fingerprints
If you're passing webClientId in configuration object to GoogleSignin.configure() make sure it's correct. You can get your webClientId from Google Developer Console. They're listed under "OAuth 2.0 client IDs".
If you're running your app in debug mode and not using webClientId or you're sure it's correct the problem might be signature (SHA-1 or SHA-256) mismatch. You need to add the following to 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 } } }
来自 here .
我还找到了 this working example在github上。
关于amazon-web-services - react-native-google-signin 与 AWS Cognito,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48819208/