Basic http authentication using jersey client

import com.sun.jersey.api.client.Client;

import com.sun.jersey.api.client.WebResource;

import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;

 

Create HTTPBasicAuthFilter object with username and password as arguments

and to client filter

 

Client client = client.addFilter(new HTTPBasicAuthFilter(username, password));

WebResource resource = client.resource(URL);

JSONObject response = resource.get(JSONObject.class);

Share on Google Plus

About Veera

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

1 comments: