I'm using 'login' option in my app.yaml configuration file for a GAE application. Looks like this:
- url: /admin/.*
script: myapp.app
login: admin
- url: /.*
script: myapp.app
login: required
UPDATE (by suggestion of bossylobster): I want a user always signed in (unsigned users can't do anything), and I need to know who the user is. Actually, I need OAuth2 credentials to communicate with Google APIs (for example, I need to fetch some user's info with Google Profiles API, and write in the user's calendar with Google Calendar API). Finally, I need an admin user to perform some operations (like create new domain's users, with Google Provisioning API)
I'm using google-api-client library, and playing around with oauth2 decorators. Then, in my RequestHandlers, I have this:
class MainHandler(webapp.RequestHandler):
@decorator.oauth_aware
def get(self):
if decorator.has_credentials():
# do something
else:
url = decorator.authorize_url()
self.response.out.write(template.render('templates/index.html',
{'authorize_url': url}))
Finally, I've read about another method:
user = users.get_current_user()
if user:
# do something
else:
greeting = ("<a href=\"%s\">Sign in or register</a>." %
users.create_login_url("/"))
self.response.out.write("<html><body>%s</body></html>" % greeting)
What is the best method to handle the user's authentication to fit my needs (see UPDATE)?
Many thanks in advance