首页 > 其他分享 >spring-boot spring-security oauth2 /oauth/token报401,403 问题

spring-boot spring-security oauth2 /oauth/token报401,403 问题

时间:2024-03-10 12:44:04浏览次数:23  
标签:oauth2 java spring 31 boot 5.3 aop ReflectiveMethodInvocation

2024-03-10 12:20:55.281 INFO 58776 --- [nio-8002-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2024-03-10 12:20:55.283 INFO 58776 --- [nio-8002-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms
2024-03-10 12:20:55.292 DEBUG 58776 --- [nio-8002-exec-2] o.s.security.web.FilterChainProxy : Securing POST /oauth/token
2024-03-10 12:21:00.952 DEBUG 58776 --- [nio-8002-exec-2] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to empty SecurityContext
2024-03-10 12:21:01.683 DEBUG 58776 --- [nio-8002-exec-2] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2024-03-10 12:21:01.689 ERROR 58776 --- [nio-8002-exec-2] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/authorization] threw exception [Filter execution threw an exception] with root cause

java.lang.StackOverflowError: null
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.31.jar:5.3.31]

 

问题原因:

 1.没有加 @Qualifier("ClientDetailsServiceImpl"),走到其他ClientDetailsService实现类了,一直达不到断点。

 // 管理客户端应用程序的信息和凭据

    @Autowired
// @Qualifier("ClientDetailsServiceImpl")
private ClientDetailsService clientDetailsService;

2. 没有设置密码,参数遗漏; clientDetails.setClientSecret(oauthClient.getClientSecret());

参考:https://github.com/workeritagent1/itagent1-braincells.git

 

标签:oauth2,java,spring,31,boot,5.3,aop,ReflectiveMethodInvocation
From: https://www.cnblogs.com/xhzd/p/18063999

相关文章

  • spring-security源码阅读-总结(二十六)
    spring-security很重?身边一提到spring-security,都觉得很重,宁愿自己写个filter快速实现认证,确实如此吗,spring-security本质也是基于servlet-filter作为切入点。作为框架,把正常验证流程差异化的地方都封装抽象出来了。我们只需要根据他的每个差异化的地方完成我们自己的配置就行......
  • spring 简单的使用 Hikari连接池 和 jdbc连接mysql 的一个简单例子
    pom.xml<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://ma......
  • Bootstrap Your Own Latent A New Approach to Self-Supervised Learning论文阅读笔记
    BootstrapYourOwnLatentANewApproachtoSelf-SupervisedLearning论文阅读笔记Abstract​ 我们提出了BYOL,一种新的自监督图像表示学习的方法。BYOL依赖于两个神经网络,即在线网络和目标网络,它们相互作用和相互学习。从一个图像的增广视图出发,我们训练在线网络来预测同一图......
  • 【Spring】jdbc
     动态数据源切换:https://www.jianshu.com/p/a042ff2ee2ae实现数据源切换的功能就是自定义一个类扩展AbstractRoutingDataSource抽象类,其实该相当于数据源DataSourcer的路由中介,可以实现在项目运行时根据相应key值切换到对应的数据源DataSource上。publicabstractclassAbs......
  • SpringCloud入门
    微服务架构的出现单体应用之殇无法快速迭代代码合并冲突,沟通成本大幅提高回归用例庞杂,无法快速迭代无法快速恢复某版本小需求有bug需要回退整个版本的功能,且需要再走一遍冗长的发布流程微服务架构优势微服务架构是在SOA(Service-OrientedArchitecture,面向服务的架......
  • springboot注册
    查询用户,判断用户名是否被占用。1.没有被占用,则注册2.被占用,则显示用户名已被占用!service:UserServiceimportcom.example.pojo.User;publicinterfaceUserService{//根据用户名查询用户UserfindByUserName(Stringusername);}mapper:UserMapper@Map......
  • spring - mvc -2
    springmvc1.@Required注解的作用是什么@Required注解用在setter方法上,它表明具有该注解的bean属性必须在配置时填充。否则,Spring容器将抛出BeanInitializationException异常。此外,@Required与@Autowired不同——因为它仅限于setter,而@Autowired则不然。@Autowired也可用于......
  • spring - mvc - @Valid
    自定义验证创建自定义验证器需要推出我们自己的注释并在我们的模型中使用它来强制执行验证规则。因此,让我们创建自定义验证器来检查电话号码。电话号码必须是至少8位数字,但不超过11位数字。1.新注释让我们创建一个新的@interface来定义我们的注释:@Documented@Constrain......
  • springboot项目构建docker镜像
    springboot项目构建docker镜像springboot项目构建成docker镜像的两种方式手动方式:将springboot项目打成一个jar包,将jar包上次到服务器的指定目录下(具备docker环境),然后在同一目录下编写Dockerfile文件,通过dockerbuild命令构建镜像,之后把镜像发布到远程仓库中。半自动方式:......
  • SpringCloud Gateway实战
    SpringCloudGateway目录SpringCloudGateway认识SpringCloudGatewaySpringCloudGateway和Zuul最核心的区别SpringCloudGateway工作模型图及解读SpringCloudGateway三大核心概念Route、Predicate、FilterSpringCloudGateway过滤器全局过滤器和局部过滤器SpringCloudGatew......