问题背景
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,代码如下: