I'm looking to get temporary AWS credentials through the Cognito Identity pool. And then that credentials should access the AWS Transcribe service.
I've created an Identity pool and checked the option of unauthenticated user, so that I don't have to provide a token when I'm calling CognitoIdentityCredentials.
Then I attached the permission for transcribe service in the unauthenticated role(Cognito_TestIdentityPoolUnauth_Role-New).
But when I'm calling the CognitoIdentityCredentials, I'm not getting the credentials.
This is my code:-
const AWS = require('aws-sdk');
AWS.config.region = 'us-east-1';
// Configure the credentials provider to use your identity pool
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
identityPoolId: 'your_pool_id',
});
let accessKeyId, secretAccessKey, sessionToken;
// Make the call to obtain credentials
AWS.config.credentials.get(function(){
// Credentials will be available when this function is called.
accessKeyId = AWS.config.credentials.accessKeyId;
secretAccessKey = AWS.config.credentials.secretAccessKey;
sessionToken = AWS.config.credentials.sessionToken;
console.log('data', accessKeyId, secretAccessKey, sessionToken);
});
The acessKeyId, secretAccessKey and sessionToken is undefined. What am I missing here?