加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Spring安全OAuth – 检查访问令牌的有效性?

发布时间:2020-12-15 01:46:46 所属栏目:大数据 来源:网络整理
导读:我正在关注Spring Security OAuth的示例代码. 当我尝试检查令牌时获得访问令牌后 curl -X POST http://localhost:9999/uaa/oauth/check_token -d "token=e3f44c4f-f8f2-45c4-9f9e-c7dd1f583a1f" 我收到以下错误: {"error":"unauthorized","error_descriptio

我正在关注Spring Security OAuth的示例代码.

当我尝试检查令牌时获得访问令牌后

curl -X POST http://localhost:9999/uaa/oauth/check_token -d "token=e3f44c4f-f8f2-45c4-9f9e-c7dd1f583a1f"

我收到以下错误:

{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}

我尝试传递客户端ID和秘密.

curl -X POST acme:acmesecret@localhost:9999/uaa/oauth/check_token -d "token=e3f44c4f-f8f2-45c4-9f9e-c7dd1f583a1f"

我获得403状态.

{"timestamp":1437683976536,"status":403,"error":"Forbidden","message":"Access is denied","path":"/uaa/oauth/check_token”}

我无法弄清楚出了什么问题.
这里的任何帮助非常感谢.

最佳答案
尝试通过以下方式使用/ check_token授权权限:

public class OAuthSecurityConfig extends AuthorizationServerConfigurerAdapter {
   @Override 
   public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception { 
       oauthServer.checkTokenAccess("permitAll()"); 
   }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读