Orkut Gmail Calendar Documents Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Webservice authentication (Python)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
epb  
View profile  
 More options Jul 15 2009, 12:33 am
From: epb <esbenbu...@gmail.com>
Date: Tue, 14 Jul 2009 12:03:33 -0700 (PDT)
Local: Wed, Jul 15 2009 12:33 am
Subject: Webservice authentication (Python)
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..


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google