赞
踩
在学习该文章时
OAuth2.0 实现单点登录_oauth2.0单点登录_一只咸鱼。。的博客-CSDN博客
[403] during [GET] to [http://nacos-order/order/info] [OrderFeignService#getOrder()]: [{"error":"insufficient_scope","error_description":"Insufficient scope for this resource","scope":"nacos-order"}]
但明明在验证服务器已经修改了资源范围并且都重启了:
根据搜索资料没有将scope添加到新的 OAuth2Request 中造成的。
地址如下:api - 使用 Spring Boot 和 OAuth2 获取此资源的范围不足 - IT工具网
java.lang.IllegalStateException: No instances available for nacos-order
由于自己的骚操作,手动用密码模式获取token,导致两个客户端资源服务token并没有都更新,一个是最新的一个是旧的,导致用OAuth2RestTemplate远程调用的时候发送上述异常!!!
新token
旧token
OAuth2RestTemplate调用另一个客户端资源服务时解析的还是旧token,所以scope没有发生变化。
但用openfeign远程调用时没有发生该问题,可能是因为在请求方配置了令牌中继
- @Configuration
- public class RequestInterceptorConfig implements RequestInterceptor {
- /**
- * 配置令牌中继
- */
- @Override
- public void apply(RequestTemplate requestTemplate) {
- OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails)
- SecurityContextHolder.getContext().getAuthentication().getDetails();
- requestTemplate.header("Authorization","Bearer" + details.getTokenValue());
- }
- }
总结:
不要自己搞骚操作!
token没有同步导致scope还是旧的
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。