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

On Feb 24, 6:39 am, Faber Fedor <faberfe...@gmail.com> wrote:
> I'm trying to get my Android app to login to my GAE app and download some
> data.  I have the name and password of the user stored in the Android app.
> I can't find the docs that tell me the process for my Android app to
> authenticate with my GAE app using my Google Accounts.
>
> Can someone show me where they are or tell me how to do what I want to do?
>
> --
>
> Faber Fedor
> Linux New Jerseyhttp://linuxnj.com
> faberfedor.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to