3

在 AWS 中使用 MobileHubConsole 时,我想通过 Android 使用 Google+ 登录。

但我收到此错误:

06-25 23:30:02.819 17675-17675/com.xxxxxx.xxxu E/SignInActivity: Sign-in with Google caused an error.
com.amazonaws.mobile.auth.core.signin.CognitoAuthException: com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Invalid login token. Incorrect token audience. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: 971e8ed4-78a1-11e8-8b4b-69de317f28ea)
    at com.amazonaws.mobile.auth.core.IdentityManager$SignInProviderResultAdapter.onCognitoError(IdentityManager.java:426)
    at com.amazonaws.mobile.auth.core.IdentityManager$SignInProviderResultAdapter.access$1000(IdentityManager.java:400)
    at com.amazonaws.mobile.auth.core.IdentityManager$3.run(IdentityManager.java:565)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    at java.lang.Thread.run(Thread.java:760)
 Caused by: com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Invalid login token. Incorrect token audience. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: 971e8ed4-78a1-11e8-8b4b-69de317f28ea)

我正在使用 AWS 提供的登录库:

aws-android-sdk-auth-ui

安卓集成:

AWSMobileClient.getInstance().initialize(getActivity(), new AWSStartupHandler() {
        @Override
        public void onComplete(AWSStartupResult awsStartupResult) {
            Log.e("SahajLOGOP", "Complete" +LoginFragment.this.getActivity()+"  ");

            SignInUI signin = (SignInUI) AWSMobileClient.getInstance().getClient(LoginFragment.this.getActivity(), SignInUI.class);
            if (LoginFragment.this.getActivity()!=null)
            signin.login(LoginFragment.this.getActivity(), MainActivity.class).execute();
        }
    }).execute();

awsconfiguration.Json:

{
"UserAgent": "MobileHub/1.0",
"Version": "1.0",
"CredentialsProvider": {
"CognitoIdentity": {
  "Default": {
    "PoolId": "ap-south-1---------",
    "Region": "ap-south-1"
  }
 }
 },
"IdentityManager": {
"Default": {}
},
{
"GoogleSignIn": {
"ClientId-WebApp": "73699------------a4q.apps.googleusercontent.com",
"Permissions": "email,profile,openid"
}
}

联合身份池 - Google 联合身份池 - OpenID IAM 身份提供商Mobile Hub Google SignIn联合身份池 联合身份池 - OpenID IAM 身份提供商 Mobile Hub 谷歌登录

4

1 回答 1

2

好的,所以我终于解决了这个问题,这是互联网上任何地方都没有提到的东西。

我的 android 应用程序使用我的旧桌面 SHA-1 密钥签名

所以要登录,我们需要生成与应用程序签名相同的 Android Client-id 密钥。

在 Google api 控制台中,Firebase 过去常常通过自己生成正确的来自行处理这个问题,但 AWS 是第 3 方,所以我必须找出问题所在。

因此,这一次我在 AWS 中使用了正确的 Android 客户端 ID,应用程序是通过该 ID 进行签名的,从而解决了问题!

这是它的样子::

在此处输入图像描述

于 2018-06-26T06:56:49.283 回答