Auth0授权者拒绝来自服务的JWT令牌-“ jwt发行者无效。应为:https://myservice.auth0.com”

Dan*_*ego 5 javascript aws-lambda auth0 aws-api-gateway

我正在遍历将auth0设置为AWS的API网关授权者的教程,列在这里:https ://auth0.com/docs/integrations/aws-api-gateway/custom-authorizers

我正在从这里使用推荐的授权者:https : //github.com/auth0-samples/jwt-rsa-aws-custom-authorizer

唯一的修改是对配置文件的修改。

但是,在测试授权器功能时,出现以下错误:

{"name":"JsonWebTokenError","message":"jwt issuer invalid. expected: https://MYSERVICE.auth0.com"}
Run Code Online (Sandbox Code Playgroud)

其中MYSERVICE是我设置的auth0 API。这很令人困惑,因为我已经通过以下方法获得了jwt令牌:

curl --request POST \
--url https://MYSERVICE.auth0.com/oauth/token \
--header 'content-type: application/json' \
--data '{"client_id":"MY_ID","client_secret":"MY_SECRET","audience":"TestApi","grant_type":"client_credentials"}'
Run Code Online (Sandbox Code Playgroud)

可以将生成的令牌通过https://jwt.io/加载到调试器工具中,并将iss字段报告为https://MYSERVICE.auth0.com。

在此处输入图片说明

是否有可能导致此问题的配置错误?

arc*_*don 6

阅读完您的问题后,通读了整个教程,这对我有用(最近已经做过)。

尚不清楚,但从有问题的错误消息中报告,看起来像预期的发行者最后没有尾随/。

但是,我的DID绝对具有该功能。这是来自JWT.IO的正在工作的令牌的屏幕截图。

在此处输入图片说明

只需发送该API(使用邮递员)并将其附加为Authorization Bearer {{token}}标头即可。使用教程的api(AWS petshop),接收输出:

[
    {
        "id": 1,
        "type": "dog",
        "price": 249.99
    },
    {
        "id": 2,
        "type": "cat",
        "price": 124.99
    },
    {
        "id": 3,
        "type": "fish",
        "price": 0.99
    }
]
Run Code Online (Sandbox Code Playgroud)

帮助您查看JWT令牌iss和aud(受众)值。

  • 我有同样的错误,并且缺少“ /” (3认同)