Jersey Client with Basic Auth
To add Basic Authentication to a web service call using the Jersey Client library a HTTPBasicAuthFilter
instance need to be added to the WebResource
.
WebResource service = Client.create().resource(url); HTTPBasicAuthFilter filter = new HTTPBasicAuthFilter(username, password); service.addFilter(filter);