Reputation: 1733
I have a webservice to access that is protected by basic HTTP authentification.
How do I set up the ODataClient to send the authentication to the web service?
ODataClient client = ODataClientFactory.getClient();
String iCrmServiceRoot = "https://example.dev/Authenticated/Service";
ODataServiceDocumentRequest odClientReq =
client.getRetrieveRequestFactory().getServiceDocumentRequest(iCrmServiceRoot);
Upvotes: 5
Views: 3995
Reputation: 1733
To access the web service you just need to add the basic HTTP authentification to the configuration as follows:
ODataClient client = ODataClientFactory.getClient();
// add the configuration here
client.getConfiguration()
.setHttpClientFactory(new BasicAuthHttpClientFactory("[username]", "[password]"));
String iCrmServiceRoot = "https://example.dev/Authenticated/Service";
ODataServiceDocumentRequest odClientReq =
client.getRetrieveRequestFactory().getServiceDocumentRequest(iCrmServiceRoot)
Upvotes: 8