in my Android App I want to create temp credentials for AWS, so that I don't have to store my secret AWS credentials in my app. I use this code to create the credentials:
CognitoCachingCredentialsProvider cognitoProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(), // get the context for the current activity
"XXXXXXXXXX",
"us-east-1:XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"arn:aws:iam::XXXXXXXXXXX:role/myUnauthRole",
"arn:aws:iam::XXXXXXXXXXX:role:role/myAuthRole",
Regions.US_EAST_1
);
AWSCredentials awsCredentials = new BasicAWSCredentials(cognitoProvider.getCredentials().getAWSAccessKeyId(), cognitoProvider.getCredentials().getAWSSecretKey());
When I try it like this, I get an error in the last line of my code with the error "Not authorized to perform sts:AssumeRoleWithWeb Identity"
. I think there is a problem with the policy that I use for myUnauthRole
and myAuthRole
. It looks like this:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "sts:GetFederationToken",
"Resource": "*"
}]
}
Is there anything else I have to do within the policy? I was snot able to find a working example for my use case on the internet. Would be great to get some support here.
Thanks!