Cognito:用户登录以验证DynamoDB:错误:配置中缺少凭据:

时间:2017-08-27 17:42:25

标签: amazon-dynamodb amazon-cognito

当我尝试使用Cognito登录经过身份验证的用户时,我收到以下错误。我正在尝试访问DynamoDB。

  

错误:配置中缺少凭据

     

“NotAuthorizedException:配置中缺少凭据

  AWS.config.update({region:'us-west-2'}); 
  if (cognitoUser != null) { cognitoUser.getSession(function(err, result) { 
    if (result) {

       console.log('You are now logged in.');
       AWS.config.credentials = new   AWS.CognitoIdentityCredentials({
               IdentityPoolId: config.IdentityPoolId,
               Logins: {
                   "cognito-idp.us-west-2.amazonaws.com/us-west-2_XXXXXXX": result.getIdToken().getJwtToken()
               }
           });
       }
   });
  }



      var  dynamoDB = new AWS.DynamoDB(AWS.config.credentials)            


       dynamoDB.listTables(function(err, data) {
           if (err) console.log(err, err.stack);
           else console.log(data.TableNames);
       });             

1 个答案:

答案 0 :(得分:0)

您需要在label

中调用dynamo
相关问题