OAuth2Decorator oauth_aware forces authentication

My understanding of the difference between oauth_awareand oauth_requiredis that it awaredoes not cause authorization, but requireddoes, but this is not what I see in practice. I have two webapp RequestHandlers below, one of which methods is get()decorated decorator.oauth_aware, and the other is decorator.oauth_required. However, when I run locally or in App Engine, both are immediately redirected to the input stream.

The goal is to SplashHandlergive the user a link to authorization, if they have not been, and if they are, then go to /tasks/.

decorator = OAuth2Decorator(
    client_id=settings.CLIENT_ID,
    client_secret=settings.CLIENT_SECRET,
    scope=settings.SCOPE,
    user_agent='mytasks')

class SplashHandler(webapp.RequestHandler):
  @decorator.oauth_aware
  def get(self):
    if not decorator.has_credentials():
      self.response.out.write(template.render('templates/convert.html',
        {'authorize_url': decorator.authorize_url()}))
    else:
      self.redirect('/tasks/')

class TasksHandler(webapp.RequestHandler):
  @decorator.oauth_required
  def get(self):
    tasks = get_tasks()
    tasks.sort(key=lambda x: x['due'])
    self.response.out.write(template.render('templates/index.html',
                                              {'tasks': tasks}))

application = webapp.WSGIApplication(
    [('/', SplashHandler), ('/tasks/', TasksHandler)], debug=True)
+5
source share
1 answer

oauth_aware : " ?". , , - , , api , , email/user-id , . oauth_required 2 , , oauth, G + Docs - .

, , , , , , .

, oauth_aware , , . , "", " ", "".

+7

All Articles