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()
}
});
}
});
}
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?