ClientLogin with GAE

31 views
Skip to first unread message

Vagabond

unread,
Nov 1, 2010, 6:44:40 PM11/1/10
to google-a...@googlegroups.com
From older posts it seems that the ClientLogin has 3 steps when you want to use it with GAE:
- Get the Auth string from "https://www.google.com/accounts/ClientLogin" with a post
- Using the Auth string, get the cookie from "http://myapp.appspot.com/_ah/login" using the abovementioned auth string as a get param, (and add a "continue" param too)
- Use the cookie for subsequent calls 

When I try the second part, I get this:
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>500 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered an error and could not complete your request.<p>If the problem persists, please <A HREF="http://code.google.com/appengine/community.html">report</A> your problem and mention this error message and the query that caused it.</h2>
<h2></h2>
</body></html>

From this I can draw two conclusions:
either: clientLogin doesn't work for GAE anymore
or: The url is not the right one

Any help with this one?

Thanks in advance


Trung

unread,
Nov 2, 2010, 9:14:33 AM11/2/10
to Google App Engine
Hi Vagabond,

For your infor, see http://code.google.com/p/gwt-syncproxy/source/browse/trunk/src/com/gdevelop/gwt/syncrpc/SyncProxy.java
and look for loginGAE method.

Hope this help.

Vagabond

unread,
Nov 2, 2010, 6:04:25 PM11/2/10
to google-a...@googlegroups.com
Thank you, Trung. This was a big help! It seems that I was on the right track, the code only needed some polishing.
I've checked the code, it was pretty similar to mine, so I've just changed one thing, and it is now working. 


For anyone having the same issue: try to inline the get parameters, like in the code above, or this:
HttpGet get = new HttpGet("http://yourapp.appspot.com/_ah/login?continue="+URLEncoder.encode("http://yourapp.appspot.com/")+"&auth="+auth.substring(5));
Where auth is the String from the first request, starting with: "Auth:"

A few other possible pitfalls I've seen:
- If the first url is wrong (should be: https://www.google.com/accounts/ClientLogin) you will get cookies in the reply, a well known one is "PREF=ID=.."
- The information that you send in should be the body of the "post" call for the first request, and "get" parameters in the second. 
- The Auth string from the first call comes back as content (in the body), not as header/cookie
- For the second call, it's better to turn off redirect following
- You don't need a CookieManager to capture the cookie. You can just look for "Set-Cookie" in the headers
- The expiry date of the cookie depends on your GAE app settings. The default is one day, you can change it to 1 or 2 weeks.
Reply all
Reply to author
Forward
0 new messages