I can see why Tony's version would work. His "algorithm" has two
steps:
1. Get the authorization token using ClientLogin (which I also managed
to do).
2. Use the uri "servername/_ah/login" to get the auth. cookie.
The appengine_rpc module seems to do authentication in a similar way:
A. Try to access the app. This results in a redirect to a location
that starts with
https://www.google.com/accounts/ServiceLogin
B. Get a auth. token (like step 1 above)
C. Use auth. token to get auth. cookie.
D. Try to access the app. again (this is where it fails in my case...)
Anyway, step C is performed using the function below:
-------
def _GetAuthCookie(self, auth_token):
"""Fetches authentication cookies for an authentication token.
Args:
auth_token: The authentication token returned by ClientLogin.
Raises:
HTTPError: If there was an error fetching the authentication
cookies.
"""
continue_location = "
http://localhost/"
args = {"continue": continue_location, "auth": auth_token}
login_path = os.environ.get("APPCFG_LOGIN_PATH", "/_ah")
req = self._CreateRequest("%s://%s%s/login?%s" %
(self.scheme, self.host, login_path,
urllib.urlencode(args)))
try:
response = self.opener.open(req)
except urllib2.HTTPError, e:
response = e
if (response.code != 302 or
response.info()["location"] != continue_location):
raise urllib2.HTTPError(req.get_full_url(), response.code,
response.msg,
response.headers, response.fp)
self.authenticated = True
------
It seems to me, that we do nothing with the response in this
function?? Shouldn't we save the cookie in the response like Tony's
does above, and then use it when we try to log in again?
On Jul 15, 1:06 pm, epb <
esbenbu...@gmail.com> wrote:
> 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...