Map<String, String> logins = new HashMap();
logins.put("cognito-identity.amazonaws.com", cognitoOpenIdToken);
GetCredentialsForIdentityRequest getCredentialsRequest =
new GetCredentialsForIdentityRequest()
.withIdentityId(cognitoIdentityId)
.withLogins(logins);
AmazonCognitoIdentityClient cognitoIdentityClient =
new AmazonCognitoIdentityClient();
GetCredentialsForIdentityResult getCredentialsResult =
cognitoIdentityClient.getCredentialsForIdentity(getCredentialsRequest);
我是不是错过了一些简单的东西?
您是否尝试过以以下方式初始化AmazonCognitoIdentityClient?
新的AmazonCognitoIdentityClient(新的AnonymousAWSCredentials());
否则,根据AWS Java SDK的设计,服务客户机将查找AWS凭据,因为相同的客户机也可以用于访问经过身份验证的API。