This is different from Jersey Client API - authentication
I need to call some REST API through Java program:
Originally I was calling API using below command:
curl https://xxx.xxx.com/api/xxx.json -v -u abc@gmail.com:XXX
Translated into Java, I got:
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(MultiPartWriter.class);
Client client = Client.create(config);
client.addFilter(new HTTPBasicAuthFilter("abc@gmail.com", "XXX"));
return client.resource("https://xxx.xxx.com/api/xxx.json");
Everything works just fine. But later on, we need to call the API through token authentication rather than username/password.
The equivalent CURL command is:
curl -u abc@gmail.com/token:ivtUYrVmVdpo3 https://xxx.xxx.com/api/xxx.json
How do I translate this into Java code??