我想使用Cognito用户池作为身份提供者 . 我验证我的用户 . 然后,我尝试通过以下步骤将此用户与用户池中的用户集成:
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()
}
});
}
});
}
但是,AWS的响应是“无效的登录令牌 . 不是有效的OpenId Connect身份令牌” .
请求有效负载如下:
{“IdentityPoolId”:“eu-west-1:idPoolValue”,“登录”:{“loginString”:“cognito-idp.eu-west-1.amazonaws.com/regionValue:id token value”}}
我用字符串替换了敏感部分 . 我已将身份池配置为使用用户池作为身份验证提供程序 .
是否有任何我错过的或未记录的步骤?
1 回答
请求有效负载的结构不正确 . 登录应该是一个映射,而不是一个具有键值对的对象 .