Hi,
I am trying to make my Python program talk to a web service hosted on
app engine. I am using the appengine-rest-server and authentication
using a Google account is required on the server. The idea is that the
user specifies his username/password in the client application, and
then the client app. will talk to app engine server via webservices.
I found this post:
http://groups.google.com/group/google-appengine/browse_thread/thread/....
The guy who replied proposes the use of Authentication for Installed
Apps, but also mentions that the GAE service should be "ah", which it
is not according to http://code.google.com/apis/base/faq_gdata.html#clientlogin
(in fact, GAE is not even listed there). What is the service name for
GAE (if it exists) and can I access the GAE application in this way?
Given the service name I should be able to talk to the server like
this:
import urllib, urllib2
# user-data
data = urllib.urlencode({'accountType' : 'GOOGLE', 'Email' :
'...@gmail.com', 'Passwd': 'xxx', 'service': 'someservice' ,
'source' : 'Me-MyApp-1.0'})
# do the log-in
f = urllib.urlopen('https://www.google.com/accounts/ClientLogin',data)
# read ClientLogin token (ugly)
line = f.readline()
token = ''
while line:
if line.startswith('Auth'):
token = line[5:]
line = g.readline()
# if we got token, login was completed
if token:
# URL to a Model called testmodel (via appengine-rest-server)
url = 'http://myappengineapp.appspot.com/rest/testmodel'
# add Authorization header with token
headers = {'Authorization': 'GoogleLogin auth='+token}
handler = urllib2.HTTPHandler()
opener = urllib2.build_opener(handler)
req = urllib2.Request(url, headers=headers)
f = opener.open(req)
# Do something with response....
# close "files"
f.close()
g.close()
Correct? In fact, I am able to login, but somehow I can't use the
token to access the GAE app..