/BasicAuth.java Secret
// instructs ODataJClient to send a BasicAuth HTTP header | |
// for username 'sampleUsername' and password ' samplePassword' | |
Configuration.setHttpClientFactory(new AbstractBasicAuthHttpClientFactory() { | |
@Override | |
protected String getUsername() { | |
return "sampleUsername"; | |
} | |
@Override | |
protected String getPassword() { | |
return "samplePassword"; | |
} | |
}); | |
// perform any operation via ODataJClient: all requests will bear the BasicAuth HTTP header | |
// this restores the default unauthenticated behavior | |
Configuration.setHttpClientFactory(new DefaultHttpClientFactory()); |
I tried using the above code pattern to test the use of BasicAuth with my OData 3.0 service end-point.. and i get the following
Dec 07, 2017 12:26:19 PM org.apache.http.impl.client.HttpAuthenticator authenticate
WARNING: Malformed challenge: Authentication challenge is empty
Exception in thread "main" com.msopentech.odatajclient.engine.communication.ODataClientErrorException: (401) Unauthorized. Login Required. [HTTP/1.1 401 Unauthorized. Login Required.]
at com.msopentech.odatajclient.engine.communication.request.ODataRequestImpl.doExecute(ODataRequestImpl.java:412)
at com.msopentech.odatajclient.engine.communication.request.retrieve.ODataServiceDocumentRequest.execute(ODataServiceDocumentRequest.java:52)
at ca.holtmann.cmms.App.main(App.java:62)
Hi Heston,
Did you find a solution for this error?
I tried using the above code pattern to test the use of BasicAuth with my OData 3.0 service end-point.. and i get the following
Dec 07, 2017 12:26:19 PM org.apache.http.impl.client.HttpAuthenticator authenticate
WARNING: Malformed challenge: Authentication challenge is empty
Exception in thread "main" com.msopentech.odatajclient.engine.communication.ODataClientErrorException: (401) Unauthorized. Login Required. [HTTP/1.1 401 Unauthorized. Login Required.]
at com.msopentech.odatajclient.engine.communication.request.ODataRequestImpl.doExecute(ODataRequestImpl.java:412)
at com.msopentech.odatajclient.engine.communication.request.retrieve.ODataServiceDocumentRequest.execute(ODataServiceDocumentRequest.java:52)
at ca.holtmann.cmms.App.main(App.java:62)