Thanks for your answers.

As I understand Nick's response, I only need to use appengine_rpc.py
for the entire process. I tried the following:

-------

def passwdFunc():
    return ('my_email','my_passwd')

rpcServer = appengine_rpc.HttpRpcServer
('myapp.appspot.com',passwdFunc,None,'myAppName')
blah = rpcServer.Send('/')

-------

This gave me a 302 error and the following log:

-------

Server: myapp.appspot.com
Sending HTTP request:
POST /? HTTP/1.1
Host: myapp.appspot.com
X-appcfg-api-version: 1
Content-type: application/octet-stream


Got http error, this is try #1
Got 302 redirect. Location:
https://www.google.com/accounts/ServiceLogin?service=ah&continue=http://myapp.appspot.com/_ah/login%3Fconti
nue%3Dhttp://myapp.appspot.com/
&ltmpl=gm&ahname=MyAppName&sig=46378246....321321312
Sending HTTP request:
POST /? HTTP/1.1
Host: myapp.appspot.com
X-appcfg-api-version: 1
Content-type: application/octet-stream


Got http error, this is try #2

-------

It seems to me that the Send() function should do all authentication-
work automatically and re-direct to the app page after logging in.
Right?

Anyway, I'll try out Tonys solution also..

On Jul 15, 11:18 am, Tony <[email protected]> wrote:
> Since I happened to have this up, here's a bit of sample code to get
> an authentication cookie for an appspot app...
>
> from google.appengine.api import urlfetch
> from urllib import urlencode
> email = request.POST['username']
> passwd = request.POST['password']
> serv_root = "http://myapp.appspot.com";
> target = 'http://myapp.appspot.com/null'
> app_name = "myapp-1.0"
> auth_uri = 'https://www.google.com/accounts/ClientLogin'
> authreq_data = urlencode({ "Email":   email,
>                                   "Passwd":  passwd,
>                                   "service": "ah",
>                                   "source":  app_name,
>                                   "accountType": "HOSTED_OR_GOOGLE" })
> result = urlfetch.fetch(auth_uri, authreq_data, method=urlfetch.POST,
> follow_redirects=False)
> auth_dict = dict(x.split("=") for x in result.content.split("\n") if
> x)
> auth_token = auth_dict["Auth"]
> serv_args = {}
> serv_args['continue'] = target
> serv_args['auth']     = auth_token
> serv_uri = "%s/_ah/login?%s" % (serv_root, urlencode(serv_args))
> result2 = urlfetch.fetch(serv_uri, follow_redirects=False,
> method=urlfetch.GET)
> ### here's the cookie which will authenticate future requests
> cookie = result2.headers['set-cookie'].split(';')[0]
> # cookie[0] => "ACSID"
> # cookie[1] => "AAAAHFSDJHSDFHSDJFHSDJFHSJFSDfsdjfhsjdfhsjdfh..."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to