You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Pablo Leira <pl...@denodo.com> on 2017/04/28 12:57:53 UTC

ODataClientErrorException: (401) Unauthorized [HTTP/1.1 401 Unauthorized]

Hi,
I am trying to consume a olingo service with basic authentication from an
implementatio of a olingo client.
For this I implemented Basic authentication in this way:
  client.getConfiguration().
                    setHttpClientFactory( new
BasicAuthHttpClientFactory(user, password));

Theoretically, this code should  run, I have seen this code in the
following case : https://issues.apache.org/jira/browse/OLINGO-705.

But I am obtaining the following error, Here it is the trace:
org.apache.olingo.client.api.communication.ODataClientErrorException: (401)
Unauthorized [HTTP/1.1 401 Unauthorized]
at
org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker.checkResponse(ODataErrorResponseChecker.java:75)
~[?:?]
at
org.apache.olingo.client.core.communication.request.AbstractRequest.checkResponse(AbstractRequest.java:54)
~[?:?]
at
org.apache.olingo.client.core.communication.request.AbstractODataRequest.doExecute(AbstractODataRequest.java:310)
~[?:?]
at
org.apache.olingo.client.core.communication.request.retrieve.XMLMetadataRequestImpl$SingleXMLMetadatRequestImpl.execute(XMLMetadataRequestImpl.java:169)
~[?:?]
at
org.apache.olingo.client.core.communication.request.retrieve.XMLMetadataRequestImpl.execute(XMLMetadataRequestImpl.java:65)
~[?:?]
at
org.apache.olingo.client.core.communication.request.retrieve.XMLMetadataRequestImpl.execute(XMLMetadataRequestImpl.java:40)
~[?:?]
at
org.apache.olingo.client.core.communication.request.retrieve.EdmMetadataRequestImpl.getPrivateResponse(EdmMetadataRequestImpl.java:63)
~[?:?]
at
org.apache.olingo.client.core.communication.request.retrieve.EdmMetadataRequestImpl.execute(EdmMetadataRequestImpl.java:77)
~[?:?]
at
org.apache.olingo.client.core.communication.request.retrieve.EdmMetadataRequestImpl.execute(EdmMetadataRequestImpl.java:35)
~[?:?]

These are the headers that the client is sending in the first request.

GET /denodo-odata4-service-5.5/denodo-odata.svc/admin/$metadata HTTP/1.1
Accept: application/xml
Content-Type: application/xml
OData-MaxVersion: 4.0
OData-Version: 4.0
Host: 192.168.0.76:8080
Connection: Keep-Alive
User-Agent: Apache-Olingo/4.3.0

These are the headers that the service send as response to the client.

HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
WWW-AUTHENTICATE: Negotiate
WWW-AUTHENTICATE: Basic
Content-Length: 0
Date: Thu, 27 Apr 2017 09:17:38 GMT

Which could be the problem?
Are there any way to configure a preemptive authentication?
Thanks.

Pablo Leira

Re: ODataClientErrorException: (401) Unauthorized [HTTP/1.1 401 Unauthorized]

Posted by Dennis Kieselhorst <de...@apache.org>.
Hi Pablo,

sounds like you have to use NTLMAuthHttpClientFactory instead of BasicAuthHttpClientFactory.

Check the logs, currently you probably see something like:
WARN o.a.h.c.p.RequestTargetAuthentication    : NEGOTIATE authentication error: Invalid name provided (Mechanism level: KrbException: Cannot locate default realm)
WARN o.a.h.c.p.RequestTargetAuthentication    : NTLM authentication error: Credentials cannot be used for NTLM authentication: org.apache.http.auth.UsernamePasswordCredentials

Cheers
Dennis