"Missing Authentication Token" 使用 AWS apiclient 时(带凭证)

"Missing Authentication Token" when using the AWS apigclient (with credentials)

更新 我通过删除旧池并创建一个新池来解决这个问题。我认为问题最终出在错误配置的 Cognito 角色上。它现在按预期工作。


我在尝试通过 API 访问受保护的 lambda(授权:AWS_IAM)时遇到 API 网关客户端 (Javascript/Browser) 的一些问题网关。

问题是在通过 apiClient 为我的 API 网关调用资源时,我一直收到 "Missing Authentication Token"。

我正在关注 "enhanced flow" 下的 Developer Authenticated Identities Authflow 参考:http://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flow.html?shortFooter=true

是否有可能完全像这样保护 lambda,或者我是否必须为我的案例使用授权方?我的印象是我从 cognito 获得的临时凭证可以在这段时间内用作 IAM,但它可以解释很多。我有一个稍后计划的授权人 - 用于保护其他资源。

实际调用lambda是这样的:

  var params = {};

  var body = {
    message: vm.message
  };

  var additionalParams = {
    headers: {},
    queryParams: {}
  };

  var apiClient = apigClientFactory.newClient( {
    accessKey    : data.awstoken.AccessKeyId,
    secretKey    : data.awstoken.SecretAccessKey,
    sessionToken : data.awstoken.SessionToken,
    region       : Config.aws.region
  });

  apiClient.testEchoPost( params, body, additionalParams )
    .then( function ( result ) {
      console.info( 'TEST_RESULT', result );
    })
    .catch( function ( error ) {
      console.error( 'dang', error );
    });
}

忘了正确回答。我不得不重新创建池(可能已经修复了角色),之后事情醒了,我可以用 AWS_IAM.

保护资源