Paul Thompson
Paul Thompson

Reputation: 3330

How to save google authentication for android between sessions

My app uses google authentication to login against an app engine backend. When i successfully log in my DefaultHttpClient gets a cookie from my App Engine domain, i was wondering if it were possible somehow to persist this cookie and then reapply it in the case of the app starting again at a later point to save from logging in every time the app starts.

Upvotes: 1

Views: 215

Answers (1)

Cuong Thai
Cuong Thai

Reputation: 1165

Yes, you can. In Android, I used App Engine Client to authenticate with app engine app and use HTTPConnection to set Cookie

HttpURLConnection connection;//Init connection here
connection.addRequestProperty("Cookie", mCookie);

mCookie is stored in SharedPreferences after you login success.

Note: In my project, Using other method(eg. HttpClient) to set cookie for each request was difficult and when I use HttpURLConnection it works well.

Tips: You should use Appstats for debugging this to see if the cookie is actually sent to the server.

Good luck

Upvotes: 3

Related Questions