Comments (15)
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.
Attached the log file: log.txt
If I can provide more information please let me know.
from okhttp-digest.
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.
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.
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.
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.
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.
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.
With the new interceptor, it looks pretty the same 😅 : log.txt
from okhttp-digest.
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.
@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.
check the following code:
client = builder
.authenticator(new CachingAuthenticatorDecorator(authenticator, authCache))
.addInterceptor(new AuthenticationCacheInterceptor(authCache))
==> .addNetworkInterceptor(logger)
.build();
from okhttp-digest.
@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.
@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.
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)
- IncompatibleClassChangeError using digest access authentication and latest OkHttp HOT 4
- Explain how to run ProxyAuthenticationManualTest HOT 4
- java.lang.NoSuchMethodError with okhttp 4.3.0 HOT 1
- Error code 401 HOT 5
- Authentication Cache Concurrent Modification Exception HOT 3
- Still getting 401 after Authentication Challenge HOT 8
- Http proxy with digest auth, error when server sends HTTP-301 redirect HOT 2
- How to use UTF-8 in basic and digest access authentication HOT 7
- Failed to resolve: com.burgstaller:okhttp-digest:1.19 HOT 5
- How to use OkHttp 3.12.x which supports API level 9+ in okhttp-digest HOT 3
- Copyright missing HOT 1
- Jcenter closing in May HOT 5
- Latest 1.x version is not in Maven Central HOT 2
- How can I Set Realm and Client Nonce in ADVANCED of Authorization Digest Auth HOT 3
- Send initial request with authentication header HOT 6
- java.lang.NoSuchFieldError HOT 17
- After putting app idle for some time it gives 401 issue for authorised request HOT 6
- Authentication fails if the site being accessed during proxy setup is HTTPS and digest authentication is used. HOT 4
- Are the `com.burgstaller:okhttp-digest` artifacts hosted on any public repo? HOT 5
- org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is **java.lang.IncompatibleClassChangeError**: Expected static method okhttp3.internal.http.RequestLine.requestPath(Lokhttp3/HttpUrl;)Ljava/lang/String; HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from okhttp-digest.