amazon-web-services - react-native-google-signin 与 AWS Cognito

标签 amazon-web-services react-native google-signin

我正在开发一个 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/

相关文章:

node.js - 如何删除DynamoDB中的多行?

javascript - 在不启动 Xcode 的情况下运行 React Native 应用程序?

java - 如何向ViewModel注册StartActivityForResult事件? [MVVM]

android - Plus.PeopleApi.getCurrentPerson 在 Play 服务 8.4 中已弃用。如何使用 GoogleSignInApi 获取用户的名字、姓氏和性别?

amazon-web-services - 如何从 Amazon S3 文件重定向到我的网站?

amazon-web-services - 如何在创建 postgres rds 时设置 log_line_prefix 的值

java - 如何使用 kms 角色将文件上传到 Amazon S3?

react-native - React Native 与 Android Pay(android) 和 Apple Pay(iOS) 集成

android - 滑动手势在 Android 上不起作用

android - 在 Android Studio 中使用应用程序实现 Google Play 登录时遇到问题