- Newest
- Most votes
- Most comments
Hello,
Thank you for posting on AWS re:Post!
I see that you have added Cognito as authorizer for your API gateway and generated access token using amplify. However, when you are passing this access token as Authorization in the header of request, you are getting response code: 401 {"message":"Unauthorized"}. Additionally, you have tried testing authorizer by passing token directly you got "Unauthorized request" error.
Firstly, I would like to inform you that you can test your authorizer by passing identity token to your authorizer from console. You can't use access token to test it. As you have mentioned that you have got access token from amplify and tried testing, Hence you are getting Unauthorized request error. You need to test it with id token.
Secondly, to use access token with your API gateway you need to add oAuth Scopes in your method and same Oauth scope needs to be present in your JWT access token for validation. Please find more details in below AWS reference document for using access token with your method.
Additionally, I would like to share below reference document which has possible solution for fixing the "401 Unauthorized" errors from an API Gateway.
https://repost.aws/knowledge-center/api-gateway-cognito-401-unauthorized
I hope this information will be helpful to you.
Thank you!!
Relevant content
- asked 2 years ago
- Accepted Answerasked 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago