views:

901

answers:

2

I'd like to be able to send a POST request from an Android app to App Engine and have it linked to the user's Google account. I read that you need to obtain an authentication token and send it with the POST request. Does Android provide a way to request this token? And how would GAE process it?

I feel like this should be easy and I'm missing something obvious.

Thanks!

+6  A: 
Nick Johnson
sweet! thanks so much nick.
ehfeng
+1  A: 

As of Android 2.0, you can use AccountManager to request an auth token for accounts of type com.google. You can then authenticate the user to an App Engine app by hitting the url:

http://[yourapp].appspot.com/_ah/login?auth=[theauthtoken]

The cookies set in the response can be piggybacked onto future requests to your app to authenticate the user against your app.

In the absence of sample code that does exactly this, you can check out the Sample Sync Adapter code (bundled with the SDK) for a general idea about requesting auth tokens.


EDIT: Just realized Nick wrote about the second part, but the AccountManager#getAuthToken bit is new as of Android 2.0.

Roman Nurik