【问题标题】:springboot APIs to use Auth0使用 Auth0 的 springboot API
【发布时间】:2022-06-11 02:01:06
【问题描述】:

我们正在尝试使用 auth0 进行 spring-boot 应用程序身份验证。 在 auth0.com 中创建常规 Web 应用程序和机器对机器应用程序,并在用户管理下添加用户。 目的是有一个登录API来验证用户并在成功验证后获取访问令牌。使用访问令牌(作为承载令牌)访问spring-boot应用程序的其他API。

我们在 auth0.com 的机器对机器应用程序配置下提供了正确的登录和回调 url。

在生成不记名令牌时,除了 client_idclient_secret 我们还提供了 grant_type (as client_credentials)audience > 作为 https:///api/v2 和 scope 与(openid profile my_scope 电子邮件角色)。

使用 client_id、client_secret、grant_type 和 Audience 生成的不记名令牌访问其他 API 时,我们遇到 401 错误。

其中,我们在使用 client_id、client_secret、grant_type、audience 和 scope 生成的不记名令牌访问其他 API 时遇到 403 错误。

403错误堆栈如下

Client is not authorized to access <<application-domain-in-auth0>>/api/v2/. You need to create a client-grant associated to this API.

我们提到了 udemy 会话 (https://www.udemy.com/course/build-secure-apis-with-auth0-and-postman/learn/lecture/12716335#overview)

关于整体方法以及我们哪里出错的任何意见。

谢谢

文卡塔马杜

【问题讨论】:

    标签: spring-boot auth0


    【解决方案1】:

    不确定它是否有帮助,但发现这与问题陈述更相关。

    https://community.auth0.com/t/how-to-generate-a-management-api-token-automatically/6376

    您需要做/检查几件事:

    在 Auth0 中创建一个非交互式客户端,用于表示您的服务。 授权非交互客户端调用Auth0管理API: 仪表板 > API > Auth0 管理 API > 非交互式客户端 > 授权您的客户端 确保在调用 /oauth/token 时使用的参数适用于您的非交互式客户端: { grant_type: 'client_credentials', client_id: '非交互式客户 ID', client_secret: '非交互式客户秘密', 观众:'https://yourdomain.auth0.com/api/v2/" } 确保您收到的访问令牌在向管理 API 发出的每个请求的 Authorization 标头中传递。授权:承载

    【讨论】:

      猜你喜欢
      • 2016-12-21
      • 2019-12-11
      • 2019-01-12
      • 2018-04-08
      • 2021-06-18
      • 2018-09-22
      • 2019-07-05
      • 1970-01-01
      • 2021-10-26
      相关资源
      最近更新 更多