我正在尝试使用Oauth2Decorator来授权应用程序 - 在gae中作为flask应用程序运行 .
我为项目创建了client-id和client-secret,并在控制台中启用了API .
下面是添加装饰器的简单函数 . 因此,当用户访问该URL时,它应重定向到身份验证,但它显示500内部服务器错误 .
任何建议为什么500错误被抛出?
from oauth2client.contrib.appengine import OAuth2Decorator
decorator = OAuth2Decorator(
client_id="abcde.apps.googleusercontent.com",
client_secret="yyyyyy",
scope="https://www.googleapis.com/auth/tasks")
@app.route("/")
@decorator.oauth_required
def welcome():
try:
#import pdb;pdb.set_trace()
return "Hi Welcome"
except Exception as e:
print e
if __name__ == '__main__':
app.run()
1 回答
oauth_required
装饰器只能用于装饰webapp.RequestHandler
实例的方法,而不是任意方法 - 它实际上使用该实例 . 这可能会使它与Flask不兼容 .检查OAuth2Decorator.oauth_required source code中
method
arg的doc字符串: