def requiresOAuth(fun):
 def decorate(self, *args, **kwargs):
  if self.client.has_access_token():
   try:
    fun(self, *args, **kwargs)
   except gdata.service.RequestError as error:
    if (error.code in [401, 403]):
     self.redirect('/oauth/request_token')
    else:
     raise
  else:
   self.redirect('/oauth/request_token')
 return decorate

def requiresOAuth ( fun ) : def decorate ( self , * args , ** kwargs ) : if self . client . has_access_token ( ) : try : fun ( self , * args , ** kwargs ) except gdata . service . RequestError as error : if ( error . code in [ 401 , 403 ] ) : self . redirect ( '/oauth/request_token' ) else : raise else : self . redirect ( '/oauth/request_token' ) return decorate
decorator for request handlers to gain authentication via oauth .