[英]How can i authenticate to my Identity/User Pool with Cognito Identity?
I have been trying to solve this for a few days now but i can't figure out what the problem is. 我一直试图解决这个问题几天,但我无法弄清问题是什么。
I have a user pool and an identity pool on AWS Cognito. 我在AWS Cognito上有一个用户池和一个标识池。 I have run the sample code and used it to log in and register users with Facebook and Google+ successfully.
我已经运行了示例代码并使用它来成功登录并注册用户和Facebook和Google+。 After login i am able to authenticate using the token to use SNS or the Sync services.
登录后,我可以使用令牌进行身份验证以使用SNS或同步服务。
I have registered a user and got a token (after logging in) with Cognito Identity. 我已经注册了一个用户,并在使用Cognito Identity获得了一个令牌(登录后)。 However the next step is to use the token to authenticate into the identity pool.
但是,下一步是使用令牌进行身份验证。 This is where i keep getting the error
这是我不断收到错误的地方
I have followed the instructions from Integrating User Pools with Amazon Cognito Identity and I get a token which I then try to pass it along with the pool id to the credentials provider. 我遵循了将用户池与Amazon Cognito Identity集成的说明,然后我获得了一个令牌,然后我尝试将其与池ID一起传递给凭证提供程序。
credentialsProvider.clear();
credentialsProvider.withLogins(loginMap).refresh();
My code fails on refresh(). 我的代码在refresh()上失败了。 At this point credentialsProvider is a AWSBasicCognitoIdentityProvider and refresh() fails in the super.refresh() which calls getIdentityId() in the abstract parent class AWSAbstractCognitoIdentityProvider
此时,credentialsProvider是一个AWSBasicCognitoIdentityProvider,而refresh()在super.refresh()中失败,它在抽象父类AWSAbstractCognitoIdentityProvider中调用getIdentityId()
@Override
public String getIdentityId() {
if (identityId == null) {
GetIdRequest getIdRequest = new GetIdRequest()
.withAccountId(getAccountId())
.withIdentityPoolId(getIdentityPoolId())
.withLogins(loginsMap);
appendUserAgent(getIdRequest, getUserAgent());
GetIdResult getIdResult = cib.getId(getIdRequest);
No matter what values i put in the loginsMap, i get the error 无论我在loginsMap中放置什么值,我都会收到错误
Invalid login token.
登录令牌无效。 Issuer doesn't match providerName
Issuer与providerName不匹配
at cid.getid(getIdRequest). 在cid.getid(getIdRequest)。
Most of the code is available to download free if you create an app in the Mobile Hub and generate the code. 如果您在Mobile Hub中创建应用程序并生成代码,则大多数代码都可以免费下载。 You can then configure authentication providers - FB, Google , etc.
然后,您可以配置身份验证提供程序 - FB,Google等。
What am I doing wrong ? 我究竟做错了什么 ?
Thanks. 谢谢。
Edit : Here are examples of what i have tried The token is always the object in the map. 编辑 :以下是我尝试过的示例。令牌始终是地图中的对象。 Below are the different keys
以下是不同的按键
OK i found the answer - I was putting in the wrong key value in the loginMap. 好的,我找到了答案 - 我在loginMap中输入了错误的键值。
it should be 它应该是
cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>
as it says in the documentation linked in the question 正如它在问题中链接的文档中所述
I don't know how I didn't see that. 我不知道我怎么没看到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.