HTTPS connection with basic auth result into Unauthorized

前端 未结 4 2003
名媛妹妹
名媛妹妹 2020-12-06 07:05

I am trying to access Basecamp API from my Android/Java source code following way ....

import org.apache.http.HttpResponse;
import org.apache.http.StatusLine         


        
4条回答
  •  清歌不尽
    2020-12-06 07:34

    Appendix on the brilliant and very helpfull answer of CSchulz:

    in http client 4.3 this:

    localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
    

    does not work anymore (ClientContext.AUTH_CACHE is deprecated)

    use:

    import org.apache.http.client.protocol.HttpClientContext;
    

    and

    localcontext.setAttribute(HttpClientContext.AUTH_CACHE, authCache);
    

    see http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/protocol/ClientContext.html

    and:

    http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/protocol/HttpClientContext.html

提交回复
热议问题