amazon web services - AWS Cognito: Access to Identity is forbidden when calling getOpenIdToken() -


after obtaining cognito identity, try openidtoken()

aws.config.credentials.get(function(err) {     if (!err) {       var cognitoidentity = new aws.cognitoidentity();       cognitoidentity.getopenidtoken({identityid: aws.config.credentials.identityid}, function(err, data) {         if (err) console.log(err, err.stack); // error occurred         else     console.log(data);           // successful response       });      } else {       console.log('cognito error: ' + err);     }   }); 

however fails with:

"notauthorizedexception: access identity 'us-east-1:xxxxx' forbidden. 

full error trace:

    post https://cognito-identity.us-east-1.amazonaws.com/ 400 (bad request)     aws-sdk.min.js:5 [aws cognitoidentity 400 0.192s 0 retries] getopenidtoken({identityid: 'us-east-1:xxxxx' }) routing.html:64 error: access identity 'us-east-1:xxxxx' forbidden.     @ (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:3548)     @ r.sequentialexecutor.r.util.inherit.calllisteners (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:28594)     @ r.sequentialexecutor.r.util.inherit.emit (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:28390)     @ a.request.n.emitevent (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:16483)     @ u.setupstates.e (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:12946)     @ r.runto (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:7:25031)     @ https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:7:25238     @ null.<anonymous> (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:12982)     @ null.<anonymous> (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:16538)     @ r.sequentialexecutor.r.util.inherit.calllisteners (https://www.example.com/bower_components/aws-sdk-js/dist/aws-sdk.min.js:6:28607) "notauthorizedexception: access identity 'us-east-1:xxxxx' forbidden. 

the 2 common reasons error are:

  • you haven't setup roles correctly in identity pool configuration.
  • you trying token authenticated identity without providing token identity provider.

please check code both scenarios above, if error still persists, please pm me identityid/identitypoolid , happy dig deeper.

thanks,
rachit


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -