【发布时间】:2017-02-10 12:18:08
【问题描述】:
我想使用 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", "Logins": { “loginString”:“cognito-idp.eu-west-1.amazonaws.com/regionValue:id 令牌值" } }
我已经用字符串替换了敏感部分。 我已将身份池配置为使用用户池作为身份验证提供程序。
是否还有我遗漏或未记录的其他步骤?
【问题讨论】:
标签: amazon-web-services amazon-cognito