I am trying to integrate a Cognito identity pool with an android application and firstly need to be able to access AWS resources from an unauthenticated user. I am using the sample code provided in the Cognito console but when I try to run that section I keep getting errors. I have created a sandbox environment with only one button and all it is doing is running the code provided by the Cognito console.
Here is the code:
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
"[IDENTITYPOOLID]", // Identity pool ID
Regions.US_EAST_1 // Region
);
Here are the errors:
I/AWSKeyValueStore: Detected Android API Level = 30
Creating the AWSKeyValueStore with key for sharedPreferencesForData = com.amazonaws.android.auth
E/AWSKeyValueStore: com.amazonaws.internal.keyvaluestore.KeyNotFoundException: Error occurred while accessing AndroidKeyStore to retrieve the key for keyAlias: com.amazonaws.android.auth.aesKeyStoreAlias
I/AWSKeyValueStore: Deleting the encryption key identified by the keyAlias: com.amazonaws.android.auth.aesKeyStoreAlias
E/AWSKeyValueStore: Error in retrieving the decryption key used to decrypt the data from the persistent store. Returning null for the requested dataKey = [IDENTITYPOOLID].identityId
D/CognitoCachingCredentia: Loading credentials from SharedPreferences
E/AWSKeyValueStore: com.amazonaws.internal.keyvaluestore.KeyNotFoundException: Error occurred while accessing AndroidKeyStore to retrieve the key for keyAlias: com.amazonaws.android.auth.aesKeyStoreAlias
I/AWSKeyValueStore: Deleting the encryption key identified by the keyAlias: com.amazonaws.android.auth.aesKeyStoreAlias
E/AWSKeyValueStore: Error in retrieving the decryption key used to decrypt the data from the persistent store. Returning null for the requested dataKey = [IDENTITYPOOLID].expirationDate
E/AWSKeyValueStore: com.amazonaws.internal.keyvaluestore.KeyNotFoundException: Error occurred while accessing AndroidKeyStore to retrieve the key for keyAlias: com.amazonaws.android.auth.aesKeyStoreAlias
I/AWSKeyValueStore: Deleting the encryption key identified by the keyAlias: com.amazonaws.android.auth.aesKeyStoreAlias
E/AWSKeyValueStore: Error in retrieving the decryption key used to decrypt the data from the persistent store. Returning null for the requested dataKey = [IDENTITYPOOLID].identityId
All other questions and documentation with the same errors have not provided a solution that works.
Android studio: 4.0
Emulators tried:
Pixel 3 XL API 30
Pixel 2 API 27
Gradle dependencies:
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.16.12'
implementation 'com.amazonaws:aws-android-sdk-core:2.16.12'
Identity Pool has access to unauthenticated identities enabled and a role associated with the unauthenticated identities. Please advise on how to get the credentialsProvider working for use with other AWS services from an Identity Pool.