oauth2 client in Spring Boot

This question is based on the solution in this thread.I implemented the top answer, but I am getting mixed results.

String stringObj = restTemplate.getForObject(http://server/rest/api/users?access_token=991949410990808314, String.class);

In code I am trying to hit a simple GET endpoint, but I am getting a 401 Unauthorized, but if I copy the rest url + token to my browser it returns the expected json object. Anyone have a clue why?

1 answer

  • answered 2018-03-13 21:31 Edgar Silva

    It is not because you need to put the "Authorization" in the headers and put in you rest call? Like

    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Basic " + base64Creds);