简体   繁体   English

AWS Cognito数据集和Google Identity Toolkit错误

[英]AWS Cognito dataset and Google Identity Toolkit error

I am using the new(somewhat) Google Identity Toolkit and I am facing a strange issue. 我正在使用新的(某种程度上) Google身份工具包 ,但遇到了一个奇怪的问题。

The JWT token generated by it is the following: 它生成的JWT令牌如下:

{
  "alg": "RS256",
  "kid": "qwYevA"
}
{
  "iss": "https://identitytoolkit.google.com/",
  "aud": "950882198692-jrb8d5t979qahaechf5gd4t3g59gpvou.apps.googleusercontent.com",
  "iat": 1444275809,
  "exp": 1445485409,
  "user_id": "05244125885327377646",
  "email": "**********@gmail.com",
  "provider_id": "facebook.com",
  "verified": false,
  "display_name": "NOT_MY_NAME",
  "photo_url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/v/t1.0-1/c155.48.597.597/s50x50/notmyphotonotmyphotonotmyphotonotmyphoto.jpg?oh=notmyphotonotmyphotonotmyphotonotmyphoto&oe=notmyphoto&__gda__=notmyphotonotmyphotonotmyphotonotmyphotonotmyphoto"
} 
{
*signature*
}

I am properly setting the iss : 我正在正确设置iss

CognitoSyncClientManager.addLogins("https://identitytoolkit.google.com/",
                  idToken.getTokenString());

The error appears whenever I try to sync a dataset: 每当我尝试同步数据集时,都会出现错误:

 Dataset dataset = syncClient.openOrCreateDataset("myTestDataset");
    dataset.put("myTestKey", "myTestValue");
    dataset.synchronize(new DefaultSyncCallback() {
        @Override
        public void onSuccess(Dataset dataset, List newRecords) {
            System.out.println(dataset.get("myTestKey"));
        }
    });

The error log: 错误日志:

com.google.identitytoolkit.demo E/DefaultSyncCallback: Failure occurred during sync
***: com.amazonaws.mobileconnectors.cognito.exceptions.DataStorageException: Failed to list records in dataset: myTestDataset
***:     at com.amazonaws.mobileconnectors.cognito.internal.storage.CognitoSyncStorage.handleException(CognitoSyncStorage.java:293)
***:     at com.amazonaws.mobileconnectors.cognito.internal.storage.CognitoSyncStorage.listUpdates(CognitoSyncStorage.java:152)
***:     at com.amazonaws.mobileconnectors.cognito.DefaultDataset.synchronizeInternal(DefaultDataset.java:388)
***:     at com.amazonaws.mobileconnectors.cognito.DefaultDataset$1.run(DefaultDataset.java:149)
***:     at java.lang.Thread.run(Thread.java:818)
***:  Caused by: com.amazonaws.AmazonServiceException: 1 validation error detected: Value '{https://identitytoolkit.google.com/=eyJhb---*MASSIVE-JWT*---c5demjsRlQtqjz8A}' at 
'logins' failed to satisfy constraint: Map keys must satisfy constraint: [Member must have length less than or equal to 128, Member must have length greater than or equal to 1, 
Member must satisfy regular expression pattern: [\w._/-]+] (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: ValidationException; Request ID: ab0d6028-6d80-11e5-ac9f-33bc83bfc548)
......
***: failed to synchronize myTestDataset

So, what could I be doing wrong? 那么,我可能做错了什么?

This is my first time working the AWS and I am fairly new with JWT aswell. 这是我第一次使用AWS,JWT也是我的新手。 Any help is appreciated. 任何帮助表示赞赏。

I should mention that I am using classes and samples from this project: https://github.com/awslabs/aws-sdk-android-samples/tree/master/CognitoSyncDemo 我应该提到我正在使用该项目中的类和示例: https : //github.com/awslabs/aws-sdk-android-samples/tree/master/CognitoSyncDemo

Google's OpenID Connect issuer name is "accounts.google.com", and that's what should be passed as the first parameter of addLogins instead of "" https://identitytoolkit.google.com/ " for Google tokens. Google的OpenID Connect发行者名称为“ accounts.google.com”,这应该作为addLogins的第一个参数而不是Google令牌的“” https://identitytoolkit.google.com/传递。

However, it looks like your token actually specifies " https://identitytoolkit.google.com/ " as issuer. 但是,您的令牌似乎实际上将“ https://identitytoolkit.google.com/ ”指定为发行者。 If that's the kind of tokens you are receiving from the Identity Toolkit, I'm afraid you won't be able to use them to authenticate with Google using Cognito as that is not a valid OpenID Connect issuer according to this . 如果这是您从身份工具包中接收到的令牌,恐怕您将无法使用它们使用Cognito向Google进行身份验证,因为根据此证书,该令牌不是有效的OpenID Connect发行者。 It might be worth asking the Identity Toolkit guys about that, because it looks like a bug on their side. 可能值得向Identity Toolkit的人询问,因为这看起来像是他们的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM