I have a Google App Engine application - http://mylovelyapp.appspot.com/ He has a page - mylovelypage
At the moment, the page just does self.response.out.write('OK')
If I run the following Python on my computer:
import urllib2 f = urllib2.urlopen("http://mylovelyapp.appspot.com/mylovelypage") s = f.read() print s f.close()
he prints ok
the problem is that i am adding login:required to this page in yaml application
then this will display the google account login HTML page
I tried the "normal" authentication approaches. eg.
passman = urllib2.HTTPPasswordMgrWithDefaultRealm() auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler.add_password(None, uri='http://mylovelyapp.appspot.com/mylovelypage', user='billy.bob@gmail.com', passwd='billybobspasswd') opener = urllib2.build_opener(auth_handler) urllib2.install_opener(opener)
But that doesn't matter - I still returned the login HTML page.
I tried the Google ClientLogin auth API , but I can't get it to work.
h = httplib2.Http() auth_uri = 'https://www.google.com/accounts/ClientLogin' headers = {'Content-Type': 'application/x-www-form-urlencoded'} myrequest = "Email=%s&Passwd=%s&service=ah&source=DALELANE-0.0" % ("billy.bob@gmail.com", "billybobspassword") response, content = h.request(auth_uri, 'POST', body=myrequest, headers=headers) if response['status'] == '200': authtok = re.search('Auth=(\S*)', content).group(1) headers = {} headers['Authorization'] = 'GoogleLogin auth=%s' % authtok.strip() headers['Content-Length'] = '0' response, content = h.request("http://mylovelyapp.appspot.com/mylovelypage", 'POST', body="", headers=headers) while response['status'] == "302": response, content = h.request(response['location'], 'POST', body="", headers=headers) print content
It seems to me that I can get some token correctly, but trying to use it in the header when I call "mylovelypage" still returns me the HTML login page. :-(
Can someone please help?
Can I use the GData client library for this? From what I read, I think it should have access to App Engine applications, but I have not been more successful in getting the authentication working there for App Engine applications, and
Any pointers to samples, articles, or even just keywords that I should be looking to get me started would be greatly appreciated.
Thank!