刷新凭据Cognito Identity时出错

时间:2018-02-21 20:03:06

标签: node.js amazon-web-services amazon-cognito

我正在尝试在节点中验证cognito用户池用户,但在刷新凭据时遇到错误(404)。我尝试使用cognitoUser.authenticateUser进行身份验证。这很成功,在onSuccess中,我使用AWS.CognitoIdentityCredentials创建凭据并获取以下内容

CognitoIdentityCredentials {
expired: true,
expireTime: null,
accessKeyId: undefined,
sessionToken: undefined,
params: 
 { IdentityPoolId: '...',
   Logins: 
    { 'cognito...': '...' } },
data: null,
_identityId: null,
_clientConfig: {} }

所以我尝试使用AWS.config.credentials.refresh刷新凭据,但是我收到此错误

{ UnknownError: Not Found
    at Request.extractError (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/protocol/json.js:48:27)
    at Request.callListeners (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/.../projects/nodekb/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/Users/.../projects/nodekb/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
  message: 'Not Found',
  code: 'UnknownError',
  statusCode: 404,
  time: 2018-02-21T19:03:29.670Z,
  requestId: '...',
  retryable: false,
  retryDelay: 81.76059666489807 }

注意:这些是我需要的两个库

const AWS = require('aws-sdk');
const AWSCognito = require('amazon-cognito-identity-js');

我按照说明here进行操作。具体用例4

2 个答案:

答案 0 :(得分:0)

我认为我的问题是我的终端设置为发电机。在AWS配置中更改了端点后,我收到了另一个错误

答案 1 :(得分:0)

( < AWS.CognitoIdentityCredentials > AWS.config.credentials).refresh((error) => {});