简体   繁体   中英

AWS Cognito, Failure to Integrate a User in a User Pool with an Identity Pool

I want to use the Cognito User Pool as the identity provider. I authenticate my user. I then try to Integrate this user with the User in the User Pool, by following these steps:

var cognitoUser = userPool.getCurrentUser();

if (cognitoUser != null) {
    cognitoUser.getSession(function(err, result) {
if (result) {
    console.log('You are now logged in.');

    // Add the User's Id Token to the Cognito credentials login map.
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    IdentityPoolId: 'YOUR_IDENTITY_POOL_ID',
    Logins: {
   'cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>': result.getIdToken().getJwtToken()
   }
  });
 }
 });
}

http://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-integrating-user-pools-with-identity-pools.html

However, the response from AWS is "Invalid login token. Not a valid OpenId Connect identity token."

The request payload was like this:

{ "IdentityPoolId": "eu-west-1:idPoolValue", "Logins": { "loginString": "cognito-idp.eu-west-1.amazonaws.com/regionValue : id token value" } }

I've replaced the sensitive parts with a string. I've configured the identity pool to use the User Pool as an authentication provider.

Are there any further steps that I've missed or that aren't documented?

The structure of the request payload was incorrect. Logins should be a map, instead it was an object with a key value pair.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM