0
votes

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?

1

1 Answers

1
votes

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