Unable to authorize requests to API Gateway using Cognito access token

0

Hi there,

I've currently ran into issues with using the access token in requests to API Gateway. The method I am testing for has a custom scope of api/admin in the OAuth scopes property in the Method Request section. Previously an ID token would work which is as expected. When the API is deployed and I attempt to request against this method again I receive a 401 Unauthorized for both the id_token and the access_token. When checking against the access_token I can see that the scope api/admin is present in the token. However any requests come back as 401.

I've also checked the authorizer within API Gateway and that when tested directly allows id_tokens to get a 200 code. But the access_token gets a 401 again.

I'm not really sure how to proceed as I have the method set to use the scope. My access_token has that scope present. And I know that the method settings are deployed as id_tokens also do not work now. Any help would be appreciated.

P.S. I have attempted different scopes in case api/admin was a protected name. But I am still getting the same error with all of them

Edited by: dev-tracker on Jan 20, 2020 5:17 PM

asked 4 years ago761 views
2 Answers
1

This problem has been resolved. The answer was that the API Gateway Authorizer was utilising a token validation expression. Which validates on the aud field within the request token.

Removal of the validation expression fixed this issue as the access_token does not have an aud field present. Only id_tokens have that field present.

answered 4 years ago
1

This problem has been resolved. The answer was that the API Gateway Authorizer was utilising a token validation expression. Which validates on the aud field within the request token.

Removal of the validation expression fixed this issue as the access_token does not have an aud field present. Only id_tokens have that field present.

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions