royclarkson / spring-rest-service-oauth

A simple OAuth protected REST service built with Spring Boot and Spring Security OAuth
Apache License 2.0
664 stars 339 forks source link

If Gson mapper is chosen, the oauth token response is empty #49

Open thilaktp opened 8 years ago

thilaktp commented 8 years ago

If I add spring.http.converters.preferred-json-mapper=gson to application.properties and add the gson dependency, the oauth token is not returned.

Removing the spring.http.converters.preferred-json-mapper=gson from the properties makes it work again. Any ideas? I want to use gson for all return types.

thilaktp commented 8 years ago
2016-03-25 00:37:08.102 DEBUG 71364 --- [           main] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Written [e51ff52a-853a-46f5-ad72-9500cb2e15d3] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.GsonHttpMessageConverter@20256a0b]
2016-03-25 00:37:08.102 DEBUG 71364 --- [           main] o.s.t.web.servlet.TestDispatcherServlet  : Null ModelAndView returned to DispatcherServlet with name '': assuming HandlerAdapter completed request handling
2016-03-25 00:37:08.102 DEBUG 71364 --- [           main] o.s.t.web.servlet.TestDispatcherServlet  : Successfully completed request
2016-03-25 00:37:08.103 DEBUG 71364 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'delegatingApplicationListener'
2016-03-25 00:37:08.103 DEBUG 71364 --- [           main] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2016-03-25 00:37:08.103 DEBUG 71364 --- [           main] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed

MockHttpServletRequest:
      HTTP Method = POST
      Request URI = /oauth/token
       Parameters = {username=[craig], password=[spring], grant_type=[password], scope=[read write], client_id=[clientapp], client_secret=[123456]}
          Headers = {Authorization=[Basic Y2xpZW50YXBwOjEyMzQ1Ng==], Content-Type=[application/x-www-form-urlencoded]}

Handler:
             Type = org.springframework.security.oauth2.provider.endpoint.TokenEndpoint
           Method = public org.springframework.http.ResponseEntity<org.springframework.security.oauth2.common.OAuth2AccessToken> org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(java.security.Principal,java.util.Map<java.lang.String, java.lang.String>) throws org.springframework.web.HttpRequestMethodNotSupportedException

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = null

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 200
    Error message = null
          Headers = {X-Content-Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate, no-store], Pragma=[no-cache, no-cache], Expires=[0], X-Frame-Options=[DENY], Content-Type=[application/json;charset=UTF-8]}
     Content type = application/json;charset=UTF-8
             Body = {}
    Forwarded URL = null
   Redirected URL = null
          Cookies = []
2016-03-25 00:37:08.158 DEBUG 71364 --- [           main] c.jayway.jsonpath.internal.CompiledPath  : Evaluating path: $['access_token']
marcellom commented 7 years ago

Hi, I have this problem as well. I created an issue on the official spring repo: https://github.com/spring-projects/spring-security-oauth/issues/1143