Reputation: 797
I try to run S3 TransferManager sample. I have problem replacing these values. I am not sure where I can get COGNITO_POOL_ID. When it is run, I can see the UI for a second, then it stopped. I need someone to help me pointing out how to find COGNITO_POOL_ID and other values in Constant class. Please provide screenshot and URL if possible. Thank you.
public class Constants {
public static final String AWS_ACCOUNT_ID = "########";
public static final String COGNITO_POOL_ID =
"Cognito_RTanahUnauth_DefaultRole";
public static final String COGNITO_ROLE_UNAUTH =
"rn:aws:iam::##########:role/Cognito_RTanahUnauth_DefaultRole";
public static final String BUCKET_NAME = "rtanah";
}
This is the logcat message
22 23:05:07.682 5718-5733/com.amazonaws.demo.s3_transfer_manager E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.amazonaws.demo.s3_transfer_manager, PID: 5718
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: com.amazonaws.AmazonServiceException: 1 validation error detected: Value 'Cognito_RTanahUnauth_DefaultRole' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+ (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: ValidationException; Request ID: 2fc575a2-baa4-11e4-a864-a7823d1dc7e2)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:820)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:439)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:245)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:1079)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getId(AmazonCognitoIdentityClient.java:361)
at com.amazonaws.auth.AWSAbstractCognitoIdentityProvider.getIdentityId(AWSAbstractCognitoIdentityProvider.java:164)
at com.amazonaws.auth.AWSAbstractCognitoIdentityProvider.refresh(AWSAbstractCognitoIdentityProvider.java:307)
at com.amazonaws.auth.AWSBasicCognitoIdentityProvider.refresh(AWSBasicCognitoIdentityProvider.java:79)
at com.amazonaws.auth.CognitoCredentialsProvider.retryRefresh(CognitoCredentialsProvider.java:568)
at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:541)
at com.amazonaws.auth.CognitoCredentialsProvider.getCredentials(CognitoCredentialsProvider.java:366)
at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentials(CognitoCachingCredentialsProvider.java:447)
at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentials(CognitoCachingCredentialsProvider.java:79)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3686)
at com.amazonaws.services.s3.AmazonS3Client.headBucket(AmazonS3Client.java:1030)
at com.amazonaws.services.s3.AmazonS3Client.doesBucketExist(AmazonS3Client.java:993)
at com.amazonaws.demo.s3_transfer_manager.Util.doesBucketExist(Util.java:68)
at com.amazonaws.demo.s3_transfer_manager.MainActivity$CheckBucketExists.doInBackground(MainActivity.java:223)
at com.amazonaws.demo.s3_transfer_manager.MainActivity$CheckBucketExists.doInBackground(MainActivity.java:218)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Upvotes: 1
Views: 1612
Reputation: 1661
If you want to create an identity pool, you can go to Cognito console and click on New Identity Pool. Once you have created the pool, it will give you a sample code which will have the identity pool id. You can use this code directly in the sample app. For more information on creating an identity pool you can read the documentation here.
If you already have an existing identity pool click on the Code Browser in Cognito console to get the code to be pasted in the sample app.
Upvotes: 4
Reputation: 1449
Navigate to Cognito under AWS services, click on your Identity Pool, then in the upper right corner click "Edit Identity Pool". Your Identity Pool Id will be directly under "Identity Pool Name". Copy all of it, and paste it into your app.
Upvotes: 0