How to call AWS API Gateway Endpoint with Cognito Id (+configuration)?

后端 未结 2 1600
误落风尘
误落风尘 2021-02-08 14:11

I want to call an AWS API Gateway Endpoint that is protected with AWS_IAM using the generated JavaScript API SDK.

2条回答
  •  忘掉有多难
    2021-02-08 15:12

    Even after following everything I was getting the same error. And the reason was I missed the "sessionToken" while initialising the apigClient.

    var apigClient = apigClientFactory.newClient({
    accessKey: AWS.config.credentials.accessKeyId, //'ACCESS_KEY',
    secretKey: AWS.config.credentials.secretAccessKey, //'SECRET_KEY',
    sessionToken: AWS.config.credentials.sessionToken, // 'SESSION_TOKEN', //OPTIONAL: If you are using temporary credentials you must include the session token
    region: 'us-east-1' // OPTIONAL: The region where the API is deployed, by default this parameter is set to us-east-1 });
    

    //OPTIONAL: If you are using temporary credentials you must include the session token -- is not really optional

提交回复
热议问题