【发布时间】:2015-01-24 01:57:13
【问题描述】:
我花了一天时间试图让 Cognito 在我的服务器上运行。我没有找到任何有帮助的文档,因为没有明确的设置示例。
我的服务器上有以下代码:
BasicAWSCredentials credentials = new BasicAWSCredentials(
"A**************",
"+y*****************************");
AmazonCognitoIdentityClient client =
new AmazonCognitoIdentityClient(credentials);
GetOpenIdTokenForDeveloperIdentityRequest tokenRequest =
new GetOpenIdTokenForDeveloperIdentityRequest();
tokenRequest.setIdentityPoolId("eu-west-1:be9d19a5-*******************");
HashMap<String, String> map = new HashMap<String, String>();
//Key -> Developer Provider Name used when creating the identity pool
//Value -> Unique identifier of the user in your <u>backend</u>
map.put("access.com.cbn.postref", "fred");
//Duration of the generated OpenID Connect Token
tokenRequest.setLogins(map);
tokenRequest.setTokenDuration(1000l);
GetOpenIdTokenForDeveloperIdentityResult result = client
.getOpenIdTokenForDeveloperIdentity(tokenRequest);
String identityId = result.getIdentityId();
String token = result.getToken();
System.out.println("id = " + identityId + " token = " + token);
我创建了一个 IAM 用户并在上面的代码中使用了公钥和私钥。我使用 Dev 在 Cognito 上创建了一个 IndentityPool。授权。代码中给出的 ID:access.com.cbn.postref。
当我运行这段代码时,我得到一个异常:
com.amazonaws.services.cognitoidentity.model.ResourceNotFoundException: 未找到 IdentityPool 'eu-west-1:be9d19a5-****************************'。 (服务:AmazonCognitoIdentity;状态码:400
生成于
GetOpenIdTokenForDeveloperIdentityResult result = client
.getOpenIdTokenForDeveloperIdentity(tokenRequest);
我完全不知道该怎么做,因为我看不出我做错了什么。我确实尝试获取 IdentityPools 列表,但返回的列表大小为 0。
【问题讨论】:
标签: java amazon-web-services token amazon-cognito