After successful Authentication with Cognito User Pool I got temporary credentials to access aws resources
var akey='';
var skey='';
var st='';
AWS.config.credentials.get(function (err) {
akey = AWS.config.credentials.accessKeyId;
skey = AWS.config.credentials.secretAccessKey;
st = AWS.config.credentials.sessionToken;
var identityId = AWS.config.credentials.identityId;
});
Using those Credentials I called API which was using IAM Authorization
function ViewMyBookings_With_Credentials() {
debugger;
var apigClient = apigClientFactory.newClient({
accessKey: akey,
secretKey: skey,
sessionToken: st,
region: 'ap-south-1'
});
var params = { };
var body = ''; // Get Request
var additionalParams = { };
apigClient.mybookingsGet(params, body, additionalParams)
.then(function (result) {
//This is where you would put a success callback
alert(result.data);
}).catch(function (result) {
debugger;
alert(result.data);
//This is where you would put an error callback
});
}
Options Request Successful and I got 200 Ok For that But for Actual Request is showing CORS Error,I am sure that there is no issue with CORS. Response Headers are showing
x-amzn-ErrorType:UnrecognizedClientException X-Cache:Error from cloudfront
I searched on AWS documentation for this but not received any positive response.
One Question addressing similar issue
But the answer is not correct/complete, Please let me know what I am missing .