【发布时间】:2017-06-30 02:18:50
【问题描述】:
是否有人在尝试使用 POST 请求 oauth/token 进行身份验证时遇到错误“访问此资源需要完整身份验证”?
卷曲命令:
curl localhost:85/oauth/token -d grant_type=password -d client_id=web_app -d username=reader -d password=reader
回应:
{"timestamp":1486841819620,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/oauth/token"}
ResourceServerConfiguration 配置
http .csrf().disable() .authorizeRequests() .antMatchers("/**").authenticated() .antMatchers(HttpMethod.GET, "/me").hasAuthority("FOO_READ")
WebSecurityConfig 配置
http .csrf().disable() .exceptionHandling() .authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
谢谢!
【问题讨论】:
-
您作为客户端,需要使用 HTTP 基本身份验证向授权服务器进行身份验证
-
Authorization: Basic base64(client_id:client_secret) -
您解决了这个问题吗?
标签: spring authentication spring-boot oauth-2.0