2017-04-03 119 views
3

我遇到了为AWS Cognito设置凭据的问题。AWS Cognito无法在CognitoIdentityCredentials上设置凭据

我有以下从AWS amazon-cognito-identity-js代码用例4.

AWS.config.credentials = new AWS.CognitoIdentityCredentials({ 
      IdentityPoolId : '...', // your identity pool id here 
      Logins : { 
       // Change the key below according to the specific region your user pool is in. 
       'cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>' : result.getIdToken().getJwtToken() 
      } 
     }); 

我已经检查了我的CognitoIdentityCredentials方法发送正确IdentityPoolIdLogins,但我得到了一个未定义的accessKeyId和sessionToken作为回报。

下面是我得到的。 CognitoIdentityCredentials {expired: true, expireTime: null, accessKeyId: undefined, sessionToken: undefined, params: Object…}

任何想法如何解决这个问题?

回答

1

之后你是否调用'AWS.config.credentials.get()'以确保凭证提供程序请求凭证?