In the end this worked,
# -*- coding: utf-8 -*-
from tipfy import RequestHandler
from werkzeug.exceptions import abort
from tipfy.auth.google import GoogleMixin
class GoogleHandler(RequestHandler,GoogleMixin):
def get(self):
'''
url = self.redirect_path()
if self.auth.session:
# User is already signed in, so redirect back.
return self.redirect(url)
self.session['_redirect'] = url
'''
if self.request.args.get('openid.mode', None):
return self.get_authenticated_user(self._on_auth)
return self.authenticate_redirect()
def _on_auth(self, user):
url = "/"
if not user:
self.abort(403)
email = user.pop('email', '')
print "email:"
#print "username:"+username
auth_id = 'google|%s' % email
print "authid"+auth_id+" "+user['name']
#self.auth.login_with_auth_id(auth_id, True)
if not self.auth.user:
user = self.auth.create_user(username=user['name'],
auth_id=auth_id, email=email, type='google')
return self.redirect(url)
username=user['name'] seems the way to get it.
Now I have another problem, suppose if I want to pass username to
another handler how can I do it. This is my likely scenario.
1. User goes to the main page.
2. User clicks "Login" link.
4. Login class has forms and stuff but has no authentication module so
it routes to the GoogleHandler class.
5. Login module receives the user information from GoogleHandler
class.
How can step 5 be accomplished?
Cheers