Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApiGatewayManagementApi - InvalidSignatureException - Credential should be scoped to correct service: 'execute-api' #1831

Closed
samstradling opened this issue Dec 23, 2020 · 1 comment · Fixed by #1835
Assignees
Labels
bug This issue is a bug.

Comments

@samstradling
Copy link

Describe the bug
When running the ApiGatewayManagementApi I get the following error:

(node:44809) UnhandledPromiseRejectionWarning: InvalidSignatureException: Credential should be scoped to correct service: 'execute-api'. 
    at deserializeAws_restJson1PostToConnectionCommandError (<project_root>/node_modules/@aws-sdk/client-apigatewaymanagementapi/dist/cjs/protocols/Aws_restJson1.js:287:41)
    ...

The signingService is currently set to apigateway rather than execute-api.

return Promise.resolve({ signingService: "apigateway", ...regionInfo });

Since this is used in SigV4 it results in it being invalid:
https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html

SDK version number
3.0.0

Is the issue in the browser/Node.js/ReactNative?
node.js

Details of the browser/Node.js/ReactNative version

$ node -v
v12.16.1

To Reproduce (observed behavior)

const {
  PostToConnectionCommand,
  ApiGatewayManagementApiClient,
} = require('@aws-sdk/client-apigatewaymanagementapi');

const API_ID = '';
const REGION = '';
const STAGE = '';
const CONNECTION_ID = '';

const apiGatewayManagementApiClient = new ApiGatewayManagementApiClient({
  endpoint: `https://${API_ID}.execute-api.${REGION}.amazonaws.com/${STAGE}`,
});

(async () => {
  const command = new PostToConnectionCommand({
    ConnectionId: CONNECTION_ID,
    Data: new TextEncoder().encode('test-message'),
  })

  const res = await apiGatewayManagementApiClient.send(command);
  console.log(res);
})();

Expected behavior
The request is signed with execute-api as the service.

@samstradling samstradling added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 23, 2020
@AllanZhengYP AllanZhengYP removed the needs-triage This issue or PR still needs to be triaged. label Dec 23, 2020
@AllanZhengYP AllanZhengYP self-assigned this Dec 23, 2020
@github-actions
Copy link

github-actions bot commented Jan 8, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants