1

I am trying to consume a secured API using basic auth, but I keep getting back 401 error. The issue is the credentials and requested URL connect successfully when using Postman. Here is the call I am making, not sure if there is anything I am missing:

public ResponseEntity randomSht(){ String username = "APIKEY"; String password = ":PASSWORD"; HttpHeaders headers = new HttpHeaders(); headers.setBasicAuth(username, password); // request url String url = "https://test.myshopify.com/admin/orders/2013413015622.json"; RestTemplate restTemplate = new RestTemplate(); HttpEntity request = new HttpEntity(headers); ResponseEntity<String> response = restTemplate.exchange( url, HttpMethod.GET, request, String.class); System.out.println(response); return response; } 

1 Answer 1

3

maybe your password is just PASSWORD, you don't need to add the :, if this is just the devider between header name and value.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.