HTTP API with JWT Authoriser

0

I have Cognito User Pool setup and used amplify setup for my page and got a ID token. I am trying to use that to authorize a HTTP API using JWT authorizer . Using the jwt.io I tried to decode the JWT and got the ISS. I have this setup .

Issuer = <iss value from token>
audience = aud (this has the app client id for the cognito user pool>
Identity source = $request.header.Authorization

Since I use the ID token, I did not setup any scope. I tried to test this with curl

curl -X POST <api endpoint> -H 'Authorization:<jsw ID token>'

I get

401: Unauthorised

Note : The API works fine if I detach the authorizer. Also, the token works fine if I create a REST API and configure the cognito authoriser

Would appreciate if someone can help.

Edited by: koude on Apr 23, 2020 6:42 PM

2回答
1

Hello, can you check the "www-authenticate" header in the response? There should be a message with additional information there.

AWS
回答済み 4年前
1

It helped. I had a wrong audience. Need to put the app_client_id of the Cognito User Pool in the "Audience" field of the JWT authorizer.

This is the value that is in the JWT for key "aud"

Thanks.

koude
回答済み 4年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ