我创建了一个使用 RS256 签名算法和http://localhost:3000/api/v1作为标识符(受众)的 API,并将 openid、phone、profile 作为范围添加到创建的 API
然后创建一个应用程序来调用上述 API,使用 RS256 签名并关闭 OIDC Conformant,因为我使用的是自定义登录页面。
我能够成功调用以下授权请求:
https://hostname.auth0.com/authorize?client_id=CLIENT_ID&redirect_uri=http://localhost:4200/dashboard&response_type=code&scope=openid%20profile&state=state&nonce=nonce&audience=https://hostname.auth0.com/userinfo
获取代码后,我能够执行令牌调用并收到 access_token
curl --request POST \ --url https://hostname.auth0.com/oauth/token \ --header 'content-type: application/json' \ --data '{"client_id":"CLIENT_ID","client_secret":"CLIENT_SECRET","audience":"localhost:3000/api/v1","grant_type":"client_credentials","code": "CODE"}'
但是在解码 JWT 令牌后,我在观众字段中看不到 userinfo 端点
因此,我在执行以下 userinfo 调用时遇到未经授权的错误,但我能够使用给定的访问令牌调用我的其他 API(安全资源)而没有任何问题。
curl --request GET \
--url 'https://hostname.auth0.com/userinfo' \
--header 'authorization: Bearer {ACCESS_TOKEN}' \
--header 'content-type: application/json'
未经授权
- 然后我尝试使用 userinfo url 作为受众值来调用令牌端点:
curl --request POST \
--url https://hostname.auth0.com/oauth/token \
--header 'content-type: application/json' \
--data '{"client_id":"CLIENT_ID","client_secret":"CLIENT_SECRET","audience":"https://hostname.auth0.com/userinfo","grant_type":"client_credentials","code": "CODE"}'
然后我收到以下错误:
{"error":"access_denied","error_description":"Client is not authorized to access \"https://hostname.auth0.com/userinfo\". You might probably want to create a \"client-grant\" associated to this API. See: https://auth0.com/docs/api/v2#!/Client_Grants/post_client_grants"}
当我在创建 API 时尝试将 userinfo url 添加为附加标识符(受众)时,我收到一条错误消息,提示“已保留提供的标识符”
请让我知道我在这里做错了什么。期待你的答复。
谢谢。