0

I'm writing a client for REST API using cookie-based authentication.

Here's the code:

HttpHeaders headers = new HttpHeaders();
headers.add("Cookie", auth_cookie);
HttpEntity<?> request = new HttpEntity<>(headers);
ResponseEntity<String> response = restTemplate.exchange(URL, HttpMethod.GET, request, String.class);

which results in 401 Unauthorized.

The same approach with POST works fine, the same request when using basic authentication is also fine. What could be the problem?

dll
  • 1
  • 1
    Most probably it's the server side that's interesting for solving this question and not the client-side as you published. – Avi Feb 04 '16 at 12:11
  • That's unfortunate since I don't have access. – dll Feb 04 '16 at 12:45
  • It sounds like the server can't handle GET request authenticated by cookies or you're passing a wrong value. I would use some external tool to try and send the request before debugging the code. If you can't do it with an external tool, you must check the server. If you can - check your code again. – Avi Feb 04 '16 at 12:48

0 Answers0