【问题标题】:Spring boot OAuth2 - Insufficient Scope for this resourceSpring boot OAuth2 - 此资源的范围不足
【发布时间】:2017-02-18 15:11:35
【问题描述】:

我有一个具有必要范围的访问令牌。我也成功访问了资源服务器。当资源服务器尝试从授权服务器获取用户主体时发生错误。我真的希望我能得到一些关于如何解决这个问题的提示或帮助

  • 访问令牌:

    {"access_token":"65ce0f1a-192f-4ad2-b7bb-cb9c7cbf0be9","token_type":"bearer","re​​fresh_token":"f1e2a49d-5b24-4e9c-b9da-567eb47d6ab7","expires_in":149, "scope":"读写信任"}

  • 资源服务器调用:

    curl -H "授权:承载65ce0f1a-192f-4ad2-b7bb-cb9c7cbf0be9" http://localhost:9001/resource/hello

  • 调用后的资源服务器输出:

    2016-10-10 10:10:06.144 INFO 411 --- [nio-9001-exec-5] o.s.b.a.s.o.r.UserInfoTokenServices:获取用户信息来自:http://localhost:9000/auth/user

端点(localhost:9000/auth/user)被执行,但我的 curl 请求总是得到以下响应:

{"error":"insufficient_scope","error_description":"Insufficient scope for this resource","scope":"read"}

【问题讨论】:

    标签: spring spring-security-oauth2


    【解决方案1】:

    我通过从资源服务器属性中删除用户信息 uri 解决了这个问题。由于我使用的是 jdbc 令牌存储,因此资源服务器可以从数据库中验证令牌的真实性,不再依赖 auth 服务器。

    【讨论】:

    • 资源服务器属性到底在哪里?
    猜你喜欢
    • 2016-08-15
    • 2020-11-30
    • 1970-01-01
    • 2021-02-07
    • 2019-02-12
    • 2018-09-11
    • 2020-11-21
    • 2023-03-12
    • 2021-02-05
    相关资源
    最近更新 更多