简体   繁体   English

Android aws cognito无效的登录令牌。 不是Cognito令牌

[英]Android aws cognito Invalid login token. Not a Cognito token

I am trying to make aws android cognito work with only developer authenticated identities . 我试图使aws android cognito仅适用于developer authenticated identities But getting the below exception (sdk version 2.2.16). 但是得到以下异常(SDK版本2.2.16)。

I have cross checked identityId and identityPoolId and both values are correct. 我已经交叉检查了identityId和identityPoolId,并且两个值都是正确的。

In the loginsMap, I am using key as " cognito-identity.amazonaws.com " and token as the openId token received from my server back end. 在loginsMap中,我将密钥用作“ cognito-identity.amazonaws.com ”,并将令牌用作从服务器后端收到的openId令牌。

The loginsMap is being set in the refresh and getIdentityId method of my android AWSAbstractCognitoDeveloperIdentityProvider class. 在我的Android AWSAbstractCognitoDeveloperIdentityProvider类的refresh和getIdentityId方法中设置了AWSAbstractCognitoDeveloperIdentityProvider

Anybody facing this kind of similar issue ? 有人遇到这种类似的问题吗?

com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Invalid login token. Not a Cognito token. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: a270a26a-18fa-11e6-add3-c1b3dbd555de)
                                                                    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:716)
                                                                    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:392)
                                                                    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199)
                                                                    at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:533)
                                                                    at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getCredentialsForIdentity(AmazonCognitoIdentityClient.java:468)
                                                                    at com.amazonaws.auth.CognitoCredentialsProvider.populateCredentialsWithCognito(CognitoCredentialsProvider.java:627)
                                                                    at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:553)
                                                                    at com.amazonaws.auth.CognitoCredentialsProvider.refresh(CognitoCredentialsProvider.java:503)
                                                                    at com.amazonaws.auth.CognitoCachingCredentialsProvider.refresh(CognitoCachingCredentialsProvider.java:463)
                                                                    at com.amazonaws.auth.CognitoCachingCredentialsProvider.getIdentityId(CognitoCachingCredentialsProvider.java:414)
                                                                    at com.amazonaws.auth.CognitoCredentialsProvider.populateCredentialsWithCognito(CognitoCredentialsProvider.java:621)
                                                                    at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:553)
                                                                    at com.amazonaws.auth.CognitoCredentialsProvider.refresh(CognitoCredentialsProvider.java:503)
                                                                    at com.amazonaws.auth.CognitoCachingCredentialsProvider.refresh(CognitoCachingCredentialsProvider.java:463)

You should put the developer provider name as key in the logins map and the SDK will take care of rotating that to "cognito-identity.amazonaws.com" for you if required. 您应该将开发者提供者名称作为登录映射中的键,SDK将根据需要将其轮换为“ cognito-identity.amazonaws.com”。

Another thing you must do is update the identity id that you get from your back end along with the token. 您必须做的另一件事是更新从后端获取的身份ID和令牌。 If the identity id in the SDK cache is A and the token says it belongs to identity id B, we will throw "Not a Cognito token." 如果SDK缓存中的标识ID为A,并且令牌表明它属于标识ID B,则我们将抛出“不是Cognito令牌”。 error. 错误。 Ideally you should use the update() method to update both identity id and token after they are refreshed from your back end. 理想情况下,从后端刷新身份ID和令牌后,您应该使用update()方法来更新它们。

Developer Authenticated Identities explains this in more detail. 开发者认证身份将对此进行详细说明。 You should also look at the flow in our sample app . 您还应该在示例应用程序中查看流程。 Hope this helps. 希望这可以帮助。

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

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