我尝试使用Spring boot2.1.4和Oauth2开发一个简单的Spring Boot和Oauth,我已经在线开发了一些示例程序,该程序具有Oauth客户端和授权服务器,问题是在访问客户端时出现以下错误本地主机:8082 /
<oauth>
<error_description>
Full authentication is required to access this resource
</error_description>
<error>unauthorized</error>
</oauth>
我在这里提到了一些类似的问题,但没有找到解决我问题的方法。
这是客户端WebSecurity的定义方式
@配置 公共类SecurityConfiguration扩展了WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests()
.antMatchers("/", "/login**").permitAll()
.anyRequest().authenticated()
.and()
.oauth2Login();
}
这是在application.yml中定义的应用程序属性
spring:
thymeleaf:
cache: false
security:
oauth2:
client:
registration:
custom-client:
client-id: R2dpxQ3vPrtfgF72
client-secret: fDw7Mpkk5czHNuSRtmhGmAGL42CaxQB9
client-name: Auth Server
scope: user_info
provider: custom-provider
redirect-uri: http://localhost:8082/login/oauth2/code/
client-authentication-method: basic
authorization-grant-type: authorization_code
provider:
custom-provider:
token-uri: http://localhost:8081/auth/oauth/token
authorization-uri: http://localhost:8081/auth/oauth/authorize
user-info-uri: http://localhost:8081/auth/user/me
user-name-attribute: name
我希望进入具有登录链接的索引页面(index.html)。
但是当我访问localhost:8082 /时得到的实际结果是这个
<oauth>
<error_description>
Full authentication is required to access this resource
</error_description>
<error>unauthorized</error>
</oauth>