Announcement Announcement Module
No announcement yet.
spring-social & spring-security-oauth Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-social & spring-security-oauth

    I have a problem with the integration of spring-social & spring-security-oauth. After authorisation my OAuth2Template gets the code from spring-security-oauth server and sends a postForAccessGrant to the spring-security-oauth application. But this ends in a 406 Not Acceptable.

    Does anyone have I idea where I should search the bug? Is this more depending on spring-social or spring-security-oauth?

    Does anyone (e.g. Craig Walls) has a working spring-social integration example with spring-security-oauth?

  • #2
    The oauth-server responses with a JSON answere and I have added jackson-core-asl & jackson-mapper-asl in my spring-social adapter but it doesn't help at all.

    I have also overwritten the following method in myOAuth2Template

    	protected RestTemplate createRestTemplate() {
    		RestTemplate restTemplate = new RestTemplate();
    		List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    		converters.add(new MappingJacksonHttpMessageConverter()); 
    		converters.add(new StringHttpMessageConverter());
    		converters.add(new FormHttpMessageConverter());
    		return restTemplate;
    But I still get a org.springframework.web.HttpMediaTypeNotAcceptable Exception: Could not find acceptable representation

    Any other ideas?
    Last edited by adrian.hoehn; May 25th, 2012, 08:41 AM.


    • #3
      My request header:
      POST /apponizer-be/oauth/token HTTP/1.1
      Accept: application/x-www-form-urlencoded, multipart/form-data
      Content-Type: application/json;charset=UTF-8
      But the answere is a HTML error code as I figured out now. (thats the reason for this 406, which is a sideproduct of the main eror)
      The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ()

      But how can I change the Accept header to application/json?
      Last edited by adrian.hoehn; May 25th, 2012, 09:40 AM.


      • #4
        What it looks like is that the Accept header is asking for form data, but the server can only give you JSON. What needs to happen is that the call through RestTemplate needs to have an Accept header that includes "application/json". I'm a little surprised that the header wouldn't already include that, but that appears to be the problem.

        I'm sorry to say that I don't have a handy example of using Spring Social with S2OAuth. From what I understand, the specific use case you're looking at is to have a Spring Social consumer connect with a REST API that is secured with S2OAuth as an OAuth provider? Is that right?

        Greenhouse exposes a REST API that is secured with S2OAuth and at one time (a long time ago) there was an experimental Greenhouse module for Spring Social. Although it worked, it was just an experiment and we ditched it. In the time that has passed since then, S2OAuth has changed a lot (Greenhouse hasn't even caught up with the latest changes) and so has Spring I wouldn't be surprised to find out that one side or the other (or both) have shifted to not play well together.

        I can't offer any quick answers at the moment, but there are plans in the near future to bring Greenhouse up to speed with the latest S2OAuth work. When that happens, I'll be sure to set aside some extra time to build out a Spring Social sample to connect with Greenhouse.


        • #5
          yes I came to the same solution. but maybe I'll have to ask in the core web forum for help how i can change this header. this is the last step of the handschake, afterwards it should work fine.
          I think it's more a resttemplate problem of my code. but I'm not so familiar with resttemplate at the moment.

          does somebody else knows how to change this accept header?