AWS Cognito,无法将用户池中的用户与身份池集成

时间:2016-10-02 11:39:32

标签: amazon-web-services amazon-cognito

我想将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()
   }
  });
 }
 });
}

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

但是,来自AWS的响应是&#34;无效的登录令牌。不是有效的OpenId Connect身份令牌。&#34;

请求有效负载如下:

  

{&#34; IdentityPoolId&#34;:&#34; eu-west-1:idPoolValue&#34;,&#34;登录&#34;:{   &#34; loginString&#34;:&#34; cognito-idp.eu-west-1.amazonaws.com/regionValue:id   令牌值&#34; }}

我用字符串替换了敏感部分。 我已将身份池配置为使用用户池作为身份验证提供程序。

是否有任何我错过或未记录的步骤?

1 个答案:

答案 0 :(得分:0)

请求有效负载的结构不正确。登录应该是一个映射,而不是一个具有键值对的对象。