java.io.IOException : No authentication challenges found

前端 未结 5 1152
长发绾君心
长发绾君心 2020-11-27 18:49

I am newbie to android and this is my first project on android. I am struggling with \"authentication\" problem for more than a day. I tried several options but none of them

5条回答
  •  醉酒成梦
    2020-11-27 19:11

    What version of Android are you testing on?

    I had difficulties with the Android authenticator during some development work on Gingerbread (I don't know if it behaves differently on later versions of Android). I used Fiddler2 to examine the HTTP traffic between my app and the server, discovering that the authenticator did not send out the authentication string for every HTTP request. I needed it to.

    Instead, I resorted to this:

    urlConnection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString("userid:pwd".getBytes(), Base64.NO_WRAP ));
    

    It's a cut-and-paste from my code. Note that urlConnection is an HttpURLConnection object.

提交回复
热议问题