Aws - Unauthenticated Access Is Not Supported for This Identity Pool in Swift

AWS Cognito: Unauthenticated access is not supported for this identity pool.

The issue was resolved with an update by AWS with Swift 3 Support.

AWS / iOS / Cognito: unauthenticated access is not supported for this identity pool

The error you're getting is explaining the issue - you're sending a request to Cognito as an unauthenticated user, meaning no logins are included/linked to that identity, while it isn't enabled for the pool.

Unauthenticated identities are an opt in feature for an identity pool, you have to enable it while creating/editing your pool from the Cognito console.

iOS AWS API Gateway : Unauthenticated access is not supported for this identity pool

After 2 days, I figure it out.

 AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:CognitoIdentityUserPoolRegion
identityPoolId:CognitoIdentityPoolId identityProviderManager:pool];

Need to set identityProviderManager.
Thank you very much.

Unauthenticated access is not supported for this identity pool

We get this error when the Identity Pool has unauthenticated access disabled and no id token was found in the login map for the application. For example, in Android applications, after initializing CognitoCachingCredentialsProvider you also need to call the setLogins() method and provide a login map.

//Relevant imports
import com.amazonaws.auth.CognitoCachingCredentialsProvider;
import com.amazonaws.regions.Regions;

//Initialize credentials provider
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
"IDENTITY_POOL_ID",
Regions.US_EAST_1
);

//Create a login map
Map<String, String> logins = new HashMap<String, String>();
logins.put("www.amazon.com", "login with Amazon token");

//Set login map
credentialsProvider.setLogins(logins);
credentialsProvider.getCredentials();

//Create clients for AWS services with credentialsProvider as a parameter in the constructor

In the above example, I assumed that 'Login with Amazon' was used. For different providers, change the key "www.amazon.com" with the appropriate token. To know the key, just decode the id token at https://jwt.io and look for iss claim. The value without https:// will be the key for the login map.

As to where to put this code, check if it is using a CognitoCachingCredentialsProvider object anywhere and then add a login map to it. To forcibily refresh credentials, call the refresh() method



Related Topics



Leave a reply



Submit