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

2개 답변
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.

답변함 4년 전
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.

답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠