Identity not found in GetCredentialsForIdentityRequest
0
Hi all,
I created a SAML Identity Pool in Cognito and tried to get a JWT from a Java fat client.
AmazonCognitoIdentity client=AmazonCognitoIdentityClientBuilder.standard()
.withRegion(Regions.EU_CENTRAL_1)
.build();
Map<String,String> logins = new HashMap<String,String>();
logins.put("arn:aws:cognito-identity:eu-central-1:123456789:identitypool/eu-central-1:fxxxxx-bxxx-4xxx-bxxx-1xxxxxxx3", "I wish I was a base64 SAML Assertion");
GetCredentialsForIdentityRequest request=new GetCredentialsForIdentityRequest()
.withIdentityId("eu-central-1:fxxxx-bxxx-4xxx-xxx-xxxxb6f3")
.withLogins(logins);
GetCredentialsForIdentityResult result= client.getCredentialsForIdentity(request);
Gave me
com.amazonaws.services.cognitoidentity.model.ResourceNotFoundException: Identity 'eu-central-1:fxxxx-bxxx-4xxx-xxx-xxxxb6f3' not found. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: ResourceNotFoundException;
I already red about setting the region which I did but without any effect.
We double checked the identity pool id
Any Ideas what could went wrong with my call?
Thanks in advance
asked 2 years ago21 views
1 Answers
0
Hi,
the secret has been unveiled. To connect as an anonymous user to a cognito identity pool you need these few lines of code:
AmazonCognitoIdentity client=AmazonCognitoIdentityClientBuilder
.standard()
.withRegion(Regions.EU_CENTRAL_1)
.withCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()))
.build();
Map<String,String> logins = new HashMap<String,String>();
logins.put("arn:aws:iam::1234567890:saml-provider/my-saml-provider", "A base64 SAML response");
GetIdRequest request = new GetIdRequest()
.withIdentityPoolId("eu-central-1:7xxxxx-cxxx-xxxx-xxx-xxxxx")
.withLogins(logins);
GetIdResult result= client.getId(request);
In the logins map you have to put the arn of the SAML provider you created in IAM using the SAML Metadata.
Edited by: drdimitri on Dec 9, 2019 1:50 AM
Edited by: drdimitri on Dec 10, 2019 5:01 AM
answered 2 years ago
Relevant questions
Can you set a Cognito Identity Pool to include all users/EC2s of the acct?
asked 2 years agoHow do I Read PrincipalTags from Cognito Identity?
asked 13 days agoVerify OpenId Connect token generated by Cognito Identity pool
Accepted Answerasked 4 years agoHow to delete a record key in Cognito identity pool dataset?
asked 15 days agoModify an Identity Pool Cognito JWT
asked 5 months agoShould I use Cognito Identity Pool OIDC JWT Connect Tokens in the AWS API Gateway?
asked a month agoCognito SAML with multiple external IdPs
Accepted Answerasked 3 years agoIdentity not found in GetCredentialsForIdentityRequest
asked 2 years agoHTTP API with JWT Authoriser
asked 2 years agoI can't get my Cognito license
asked 13 days ago