Giter Site home page Giter Site logo

Comments (15)

rburgst avatar rburgst commented on July 23, 2024

hey, I would need a transcript of the whole conversation (i.e. the cases where the messages previous auth failed, cached auth expired were being logged) to better understand whats going on.

from okhttp-digest.

SailReal avatar SailReal commented on July 23, 2024

Attached the log file: log.txt

If I can provide more information please let me know.

from okhttp-digest.

rburgst avatar rburgst commented on July 23, 2024

the log unfortunately does not contain the network calls and security headers. Please make sure that you configure the logger as a network interceptor and make sure that all headers (specifically Authorization) are logged.

https://github.com/square/okhttp/wiki/Interceptors

from okhttp-digest.

rburgst avatar rburgst commented on July 23, 2024

also, the log message comes from the BasicAuthenticator somehow it seems that you are not using the digest authenticator? In case you provide the log containing BASIC authentication, you will probably want to mask the Authorization header as it will contain an unencrypted username/password. Just replace the Basic authentication header with some gibberish (but make sure its the same when the original headers are the same, too).

from okhttp-digest.

SailReal avatar SailReal commented on July 23, 2024

Yea sorry, using an LogginIntercepter which hides the sensitive data...here is a log using the mentioned Interceptor: log.txt. As mentioned before, sometimes it is working without problems:
log.txt

We from the client side are supporting both, the BasicAuthenticator and the DigestAuthenticator.

from okhttp-digest.

rburgst avatar rburgst commented on July 23, 2024

sorry to be a pain in the back but I do need to see all the headers along with the response codes.

what I find strange is that the following request

03-11 10:27:01.668 7128-7179/ I/okhttp: Sending request https://webdav.pcloud.com/0/testVault/d/6W/JTCD5CJCIZHSOUL77ZOEO2M3JWCTV6 on null

doesnt appear to contain an auth header

but the response seems to be successful anyway

03-11 10:27:02.338 7128-7179/ I/okhttp: Received response for https://webdav.pcloud.com/0/testVault/d/6W/JTCD5CJCIZHSOUL77ZOEO2M3JWCTV6 in 670.4ms

also the response does contain an WWW-Auth... header however, the client still comes back with an auth header.

03-11 10:27:02.339 7128-7179/ I/okhttp: Sending request https://webdav.pcloud.com/0/testVault/d/6W/JTCD5CJCIZHSOUL77ZOEO2M3JWCTV6/ on null
...
                                                       Authorization: Basic foo==

Somehow this doesnt add up.

from okhttp-digest.

SailReal avatar SailReal commented on July 23, 2024

Everything fine 😄 but I used the mentioned logging interceptor and that interceptor should log all headers or?

Request request = chain.request();

long t1 = System.nanoTime();

Timber.tag("okhttp").i(String.format("Sending request %s on %s%n%s",
		request.url(), chain.connection(), request.headers()));

Response response = chain.proceed(request);

long t2 = System.nanoTime();
Timber.tag("okhttp").i(String.format("Received response for %s in %.1fms%n%s",
		response.request().url(), (t2 - t1) / 1e6d, response.headers()));

return response;

from okhttp-digest.

rburgst avatar rburgst commented on July 23, 2024

In principle this doesnt look wrong, however, i typically use the following https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor

from okhttp-digest.

SailReal avatar SailReal commented on July 23, 2024

With the new interceptor, it looks pretty the same 😅 : log.txt

from okhttp-digest.

emezias avatar emezias commented on July 23, 2024

Is there an example project? When I'm trying to show the login UI dialog after a previous login failure I also get into trouble with the "previous basic authentication failed, returning null".
Is there a code sample I can use to validate I have the correct OKHttp3 connection configured?

from okhttp-digest.

rburgst avatar rburgst commented on July 23, 2024

@SailReal you did not configure the interceptor as a networkInterceptor

03-12 14:55:23.868 10923-10958/ W/OkHttp: previous basic authentication failed, returning null
03-12 14:55:25.500 10923-10958/ W/OkHttp: previous basic authentication failed, returning null
03-12 14:55:25.500 10923-10958/ D/OkHttp: Cached authentication expired. Sending a new request.

these log lines show that there were multiple roundtrips being made but they didnt end up in the log. Please configure the interceptor as a network interceptor.

from okhttp-digest.

rburgst avatar rburgst commented on July 23, 2024

check the following code:

client = builder
                    .authenticator(new CachingAuthenticatorDecorator(authenticator, authCache))
                    .addInterceptor(new AuthenticationCacheInterceptor(authCache))
==>              .addNetworkInterceptor(logger)
                    .build();

from okhttp-digest.

emezias avatar emezias commented on July 23, 2024

@rburgst - is your comment for me? I'm using a singleton of the DispatchingAuthenticator because I have both Basic and Digest. When I give Digest a bad username and password I can't get the app to display the dialog again. There is a warning from oktthp3
W/OkHttp: previous basic authentication failed, returning null

The basic authentication scheme is working. It shows the dialog again and again in case of error and login can be canceled by the user. However, the Digest scheme does not work that way. The authenticator code to display the username/password dialog fragment is not triggered a second time. I spent a bunch of hours on it now and it looks like the app triggers the webview mechanism (onReceivedHttpAuthRequest) in the loaded page if the scheme is digest and the first attempt to authenticate fails. Do you have any suggestions? Do you know a way to get the app back to okhttp3 if the auth request is triggered in webview when the link is tapped the second time?

My stuff is complicated by resource sharing between the Basic and Digest schemes that means uninstall is required between tests. My app also requires dynamic setting of credentials so I extended the Credentials object and set up a CredentialsProvider interface.
#41
It doesn't seem to matter whether or not I set up the Interceptor. With or without the AuthenticationCacheInterceptor configuration, Basic works and Digest doesn't.

I appreciate the help. Again, a reference project for this library to help developers connect UX points that go along with the authentication transactions (e.g. login success message) could be useful.

from okhttp-digest.

rburgst avatar rburgst commented on July 23, 2024

@emezias no, the response was for @SailReal, I would suggest that you open a different ticket since it sounds like your problem is a different one. Please also provide a code sample of how you setup the ok http client.

from okhttp-digest.

SailReal avatar SailReal commented on July 23, 2024

Thanks a lot for your feedback @rburgst!

Unfortunately I'm not able to reproduce this error anymore using pCloud. Will close this issue because it seems like they fixed something on the server side...thanks again for your help 😄

from okhttp-digest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.