问题背景
SpringBoot采用Spring Security集成oauth2登录时,默认地址为/oauth/token,如果想要自定义地址,比如加前缀后,再次调用时就报错,报错信息如下:
程序异常:org.springframework.security.authentication.InsufficientAuthenticationException: There is no client authentication. Try adding an appropriate authentication filter.
改这个地址的起因是两个项目希望共用一个地址,如matecloud微服务模块使用mate-uaa/oauth/token调用,springboot默认就是/oauth/token方式,希望共用一个,如果直接修改,则报上述错误。
解决方案
在AuthorizationServerConfigurerAdapter的设置内置端点EndPoint路径时自定义pathMapping,代码如下:
@Override
public

本文介绍了在Spring Boot使用Spring Security和OAuth2时,如何自定义/oauth/token登录地址以解决多个项目共享同一地址的问题。通过在AuthorizationServerConfigurerAdapter中设置pathMapping来定制端点路径,避免调用时出现错误。
最低0.47元/天 解锁文章
1515

被折叠的 条评论
为什么被折叠?



