Closed johnEthicalTechnology closed 2 years ago
I have encountered with the same issue creating REST API through amplify app. Any updates/workarounds?
@yugrinkov I've not tried it myself yet, but a potential work around could be a custom authorizer: https://docs.amplify.aws/lib/restapi/authz/q/platform/js/#cognito-user-pools-authorization
Actually, maybe not: https://github.com/aws-amplify/amplify-cli/issues/2679
@johnEthicalTechnology, yes, thanks for assistance. Properly configured authorizer fixed issue in my use case.
@yugrinkov I'm looking to use an authorizer as well. Was it as difficult to setup as the issue I posted suggests?
Nope, I just setup authorizer based on Cognito user pool according to this docs: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate-with-cognito.html
Hi @johnEthicalTechnology 👋 thanks for raising this issue! How did you try to reach your API? It looks like you chose only the update
http method during the api configuration for authenticated users.
The request you made seems to be a POST request, which would correlate to the create
option in the CLI prompt.
XHRPOSThttps://24cvd91uw6.execute-api.ap-southeast-2.amazonaws.com/dev/test
I think you should do a PUT request instead, or extend the methods available to the user to be able to create/make POST requests.
Request
const testAPI = async () => {
try {
const res = await API.put("test", "/test");
console.log(res);
} catch (error) {
console.error(error);
}
};
Response
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, REST API, GraphQL API, Storage
Amplify Categories
auth, storage, function, api
Environment information
Describe the bug
I run a post request on a REST API that has been given authorization to update and I get
AccessDeniedException
response.Expected behavior
I expect to receive the 'Hello from Lambda!' response.
Reproduction steps
Below is the amplify CLI commands I followed.
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
This is the response message:
This is the request and response:
This is the lambda function:
I was also getting an
InvalidSignatureException
error when I was using a GET request to the API that had been set up for UPDATE and FETCH, but for this particular setup I only configured it to use UPDATE permissions. I read the following issue reports about it:But couldn't find anything that was helpful. I even tried to adjust the object being passed into
Amplify.configure()
like so as per the workaround in one of the issue reports above, but it didn't work: