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

已提問 4 年前檢視次數 790 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南