Hi Faber,
Here is the information on how you generically log into Google
services and GAE app programatically:
http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
http://stackoverflow.com/questions/101742/how-do-you-access-an-authenticated-google-app-engine-service-from-a-non-web-pyt/499124
Here is the code I wrote for Android:
Log.d(TAG, "Num cookies before login: " + httpclient.getCookieStore
().getCookies().size());
//Setup Google.com login request parameters
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("Email", username));
nvps.add(new BasicNameValuePair("Passwd", password));
nvps.add(new BasicNameValuePair("service", "ah"));
nvps.add(new BasicNameValuePair("source", "YOUR-PROJECT-NAME")); //
used by google for accounting
nvps.add(new BasicNameValuePair("accountType", "GOOGLE")); //using
HOSTED here will do bad things for hosted accounts
//Login at Google.com
HttpPost httpost = new HttpPost("https://
www.google.com/accounts/ClientLogin");
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = httpclient.execute(httpost);
Log.i(TAG, "Google.com Login Response: " + response.getStatusLine
());
//Find authkey in response body to pass to
Appspot.com
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
response.getEntity().writeTo(ostream);
String strResponse = ostream.toString();
Log.v(TAG, strResponse);
StringTokenizer st = new StringTokenizer(strResponse, "\n\r=");
String authKey = null;
while(st.hasMoreTokens()) {
if(st.nextToken().equalsIgnoreCase("auth")) {
authKey = st.nextToken();
Log.d(TAG, "AUTH = " + authKey);
break;
}
}
//Do a GET with authkey to get cookie from
Appspot.com
HttpGet httpget = new HttpGet("
YOURAPP.APPSPOT.COM /_ah/login?
auth=" + authKey + "&continue=" + URL_OF_PAGE_YOU_WANT);
response = httpclient.execute(httpget)
Log.i(TAG, "Appspot.com Login Response: " + response.getStatusLine
());
Log.d(TAG, "Num cookies after login: " + httpclient.getCookieStore
().getCookies().size());
Let me know if this works for you. I pulled it together from
different parts of my code so I might have messed something up. For
simplicity I left out the error checking.
Lenza
http://blog.lenza.org