spring oauth从令牌获取用户详细信息

时间:2015-11-24 13:27:57

标签: java spring oauth netflix-zuul

我想使用spring和oauth,到目前为止似乎有效。 现在我添加了一个配置如下的zuul代理:

spring:
  oauth2:
    sso:
      home:
        secure: false
        path: /,/**/*.html
    client: 
      accessTokenUri: http://${authserver.hostname}:${authserver.port}/${authserver.contextPath}/oauth/token
      userAuthorizationUri: http://${authserver.hostname}:${authserver.port}/${authserver.contextPath}/oauth/authorize
      clientId: webapp
      clientSecret: secret
    resource:
      id: apis
      userInfoUri: http://${authserver.hostname}:${authserver.port}/${authserver.contextPath}/rest/me
      preferTokenInfo: false

每当我尝试访问资源服务器时,它都会尝试验证我的身份验证,但我的authserver端点似乎返回text / html而不是json。

 Created GET request for "http://localhost:8091/userauth/rest/me"
2015-11-24 14:07:12.275 DEBUG 3601 --- [nio-8080-exec-3] o.s.s.oauth2.client.OAuth2RestTemplate   : Setting request Accept header to  [application/json, application/*+json]
2015-11-24 14:07:12.287 DEBUG 3601 --- [nio-8080-exec-3] o.s.s.oauth2.client.OAuth2RestTemplate   : GET request for "http://localhost:8091/userauth/rest/me" resulted in 200 (OK)
2015-11-24 14:07:12.288  INFO 3601 --- [nio-8080-exec-3] o.s.c.s.o.r.UserInfoTokenServices        : Could not fetch user details: class org.springframework.web.client.RestClientException, Could not extract response: no suitable HttpMessageConverter found for response type [interface java.util.Map] and content type [text/html;charset=UTF-8]

我已经强迫json,当通过curl直接访问auth服务器时,我得到了json格式的主体。

@RequestMapping(value="/me", produces = "application/json")
public Principal getCurrentLoggedinUser(Principal user){
    return user;
}

如何将json发送到我的zuul代理,以便验证我的身份验证?

0 个答案:

没有答案