Android : Django Session Management in Android

on Friday, July 11, 2014


I have an Android client talking to a Django backend. These are the steps I do to log in the user.



  1. GET the login page.

  2. Fetch the sessionid and csrftoken cookies.

  3. POST back with the username, password and the sessionid and csrftoken cookies.


So far so good. I am able to login.


But when I want to GET any other page which requires the user to be logged in, I get an error.


I viewed the page in a browser, and found that it only requires the sessionid and csrftoken cookies, which I am supplying.


But I still get the following error:



java.io.IOException: No authentication challenges found
at libcore.net.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:436)
at libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:416)
at libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:365)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:301)
at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177)



Why would authentication fail when I supply the the sessionid and the csrftoken?


Thanks!


0 comments:

Post a Comment