{"action":"created","issue":{"url":"https://api.github.com/repos/rburgst/okhttp-digest/issues/8","repository_url":"https://api.github.com/repos/rburgst/okhttp-digest","labels_url":"https://api.github.com/repos/rburgst/okhttp-digest/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/rburgst/okhttp-digest/issues/8/comments","events_url":"https://api.github.com/repos/rburgst/okhttp-digest/issues/8/events","html_url":"https://github.com/rburgst/okhttp-digest/issues/8","id":148673328,"number":8,"title":"DigestAuthenticator returning 401 when the nonce isn't valid anymore","user":{"login":"N4zroth","id":4092857,"avatar_url":"https://avatars.githubusercontent.com/u/4092857?v=3","gravatar_id":"","url":"https://api.github.com/users/N4zroth","html_url":"https://github.com/N4zroth","followers_url":"https://api.github.com/users/N4zroth/followers","following_url":"https://api.github.com/users/N4zroth/following{/other_user}","gists_url":"https://api.github.com/users/N4zroth/gists{/gist_id}","starred_url":"https://api.github.com/users/N4zroth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N4zroth/subscriptions","organizations_url":"https://api.github.com/users/N4zroth/orgs","repos_url":"https://api.github.com/users/N4zroth/repos","events_url":"https://api.github.com/users/N4zroth/events{/privacy}","received_events_url":"https://api.github.com/users/N4zroth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-15T14:19:56Z","updated_at":"2016-04-27T03:33:44Z","closed_at":null,"body":"Hi,\r\nI run into problems with the AuthenticationCacheInterceptor: The CachingAuthenticator seems to cache a successful digest authentication (which is of course correct so far) and tries to reuse it on subsequent request (also correct).\r\nThe problem is that the request might be several seconds later than the original request thus invalidating the nonce.\r\nIn previous versions, this was fine as the authenticator just tried again until OkHttp's request limit (20) was reached. As the authentication itself was correct, the next request worked fine.\r\nBut the following code in DigestAuthenticator prevents any request after an unsuccessful authentication to be executed:\r\n\r\n`// prevent infinite loops when the password is wrong`\r\n`final String authorizationHeader = request.header(\"Authorization\");`\r\n`if (authorizationHeader != null && authorizationHeader.startsWith(\"Digest\")) {`\r\n`    Log.w(TAG, \"previous digest authentication failed, returning null\");`\r\n`    return null;`\r\n`}`\r\n\r\nIt does prevent infinite loops (well 'infinite' as in a maximum of 20 requests) on invalid passwords but it doesn't take into consideration that something else (e. g. the previously cached nonce) was wrong.\r\nIs there a simple way to fix this? I've removed the code and my authentication works fine again.\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/rburgst/okhttp-digest/issues/comments/214961047","html_url":"https://github.com/rburgst/okhttp-digest/issues/8#issuecomment-214961047","issue_url":"https://api.github.com/repos/rburgst/okhttp-digest/issues/8","id":214961047,"user":{"login":"rburgst","id":22971,"avatar_url":"https://avatars.githubusercontent.com/u/22971?v=3","gravatar_id":"","url":"https://api.github.com/users/rburgst","html_url":"https://github.com/rburgst","followers_url":"https://api.github.com/users/rburgst/followers","following_url":"https://api.github.com/users/rburgst/following{/other_user}","gists_url":"https://api.github.com/users/rburgst/gists{/gist_id}","starred_url":"https://api.github.com/users/rburgst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rburgst/subscriptions","organizations_url":"https://api.github.com/users/rburgst/orgs","repos_url":"https://api.github.com/users/rburgst/repos","events_url":"https://api.github.com/users/rburgst/events{/privacy}","received_events_url":"https://api.github.com/users/rburgst/received_events","type":"User","site_admin":false},"created_at":"2016-04-27T03:33:44Z","updated_at":"2016-04-27T03:33:44Z","body":"This is indeed a bug and I need to fix it, in the meantime its probably good for you to roll back to the previous version."}}