I’m doing authentication of android app against an app engine server, basically following this post: http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app.
It appears that the cookie that I get at the end of the process is no good – I’m getting 401, so I tried copying the cookie and testing it in the browser, and still getting 401. When copying the browser cookie to the android app, the request works.
How could I be getting an invalid cookie? I’ve even tried invalidating the tokens, but still getting the same result…
For some reason this worked: I changed the URL for the initial cookie request from https to http, then changed it back.
But in the end I decided to change my implementation and go with loopj as alistair suggested. The result is far more elegant. This is my login activity (note that I’m connecting the client to a persistent cookie storage given by loopj api):
Because loopj gives persistent cookie storage, all I have to do in another activity is to initialize a client and connect it with the persistent cookie storage. This gives the new client all of the cookies I got from the login activity. Initialization looks something like this:
BTW & FYI: The loopj library uses the
SharedPreferencesAPI in order to store the cookies, and wraps it nicely asPersistentCookieStore.