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);
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With