Search code examples
javaandroidamazon-web-servicesamazon-cognitoamazon-polly

Get Credentials from Amazon Cognito in pure Java


how can I get credentials like access key security key and session token from Amazon Cognito Identity in pure java using only IDENTITY_POOL_ID and Region?

Like on Android but without application context

CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
  getApplicationContext(), // Context
  "IDENTITY_POOL_ID", // Identity Pool ID
  Regions.US_EAST_1 // Region
);

Is it possible with Amazon SDK for Java or pure Http request? If it is, how can I do it?


Solution

  • I've found a solution, CognitoCachingCredentialsProvider extends CognitoCredentialsProvider so just use base class

    CognitoCredentialsProvider credentialsProvider = new CognitoCredentialsProvider(
                COGNITO_POOL_ID,
                MY_REGION
        );