1
這工作得很好:延遲加載Oauth2Decorator callback_handler使用webapp2的
secrets = 'client_secrets-gae.json'
decorator = OAuth2DecoratorFromClientSecrets(os.path.join(os.path.dirname(__file__), secrets),
scope='https://www.googleapis.com/auth/drive')
....
webapp2.Route('/oauth2callback', handler=decorator.callback_handler()),
但我怎麼能延遲加載回調using webapp2。我不得不提及裝飾實例:
webapp2.Route(r'/products', handler='handlers.ProductsHandler', name='products-list', handler_method='list_products')
更新和解決
此行decorator.callback_handler()
創建一個請求處理程序的對象。
decorator_callback_handler = decorator.callback_handler()
....
webapp2.Route('/oauth2callback', handler='my_package.my_mod.decorator_callback_handler'),
當然,我使用不同的模塊來處理裝飾器和webapp2路線,以從延遲加載中受益。