我正在浏览将 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"}
其中 MYSERVICE 是我设置的 auth0 api。这很令人困惑,因为我已经通过这种方法获得了 jwt token :
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"}'
生成的 token 可以加载到位于 https://jwt.io/ 的调试器工具中,并将 iss 字段报告为 https://MYSERVICE.auth0.com
是否存在可能导致此问题的错误配置?
最佳答案
在阅读您的问题后通读了整个教程,这对我有用(最近已经这样做了)。
不清楚,但从您报告的错误消息来看,预期的发行人似乎没有尾随 /
。
但是,我的确实有。这是来自 JWT.IO 的正在运行的 token 的屏幕截图。
可以简单地发送 API(使用 postman )并将其附加为 Authorization Bearer {{token}} header 。使用教程的 api (AWS petshop),接收输出:
[
{
"id": 1,
"type": "dog",
"price": 249.99
},
{
"id": 2,
"type": "cat",
"price": 124.99
},
{
"id": 3,
"type": "fish",
"price": 0.99
}
]
有助于查看您的 JWT token iss
和 aud
(受众)值。
关于javascript - Auth0 授权者拒绝来自服务的 JWT token - "jwt issuer invalid. expected: https://myservice.auth0.com",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49410108/