Why do I get android java.io.IOException: No authentication challenges found?
I thing problem in concatenation
i.e.
String basicAuth = "Basic " + Base64.encodeToString("mail@mail.com:123123".getBytes(), Base64.NO_WRAP);
connection.setRequestProperty("Authorization", "basic " + basicAuth );
No need to bind "basic" with already encoded string (basicAuth).
Try to change with below code:
String basicAuth = "Basic " + Base64.encodeToString("mail@mail.com:123123".getBytes(), Base64.NO_WRAP);
connection.setRequestProperty("Authorization",basicAuth);
I hope it work.
Volley: No authentication challenges found
Okay, I found a solution. The helper class contained an overriding getparams method, but no getheaders method. GET request requires getheaders, post requires getparams.
Android Volley - Strange Error with HTTP code 401- java.io.IOException: No authentication challenges found
I have do some research and come to conclusion that, this is a server issue, that did not follow the convention.
From wiki:
401 Unauthorized (RFC 7235)
Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication.
I think the best way to solve this problem is to solve in the server by add the header (something like:
WWW-Authenticate: xBasic realm=""
For me, I cannot change the server, so I have to check the error message to detect that a 401 error:
if (error.getMessage().equalsIgnoreCase("java.io.IOException: No authentication challenges found")){
showLoginError();
}
Not very elegant solution but work for now.
Related Topics
Creating Runnable Jar with Gradle
How to Access a Folder Inside of a Resource Folder from Inside My Jar File
What Is Difference Between @+Id/Android:List and @+Id/List
Send Sms Until It Is Successful
Why Hypot() Function Is So Slow
Can CSS in Javafx Be Used for Animations
Javafx - Border Radius <-> Background Color
How Apply CSS on a <H:Inputtext>
Add Custom CSS to HTML Code with Jsoup
What Exactly Does Urlconnection.Setdooutput() Affect
Java.Lang.Runtimeexception: Takepicture Failed
How to Get Count of Number Methods Used in a Jar File
Android: Email Client Receiver Email Id Empty in Android-Parse