OAuth 2 Decorator + Flask = AssertionError:视图函数映射覆盖现有端点函数:check_oauth

时间:2016-05-17 02:42:41

标签: python google-app-engine oauth flask google-api

我一直在努力让OAuth的Google API装饰器与Google Appengine上的Flask一起使用,但到目前为止还没有成功。使用默认设置非常简单:app = webapp2.WSGIApplication结构。

decorator = OAuth2DecoratorFromClientSecrets(os.path.join(os.path.dirname(__file__), 'client_secrets.json'), 'https://www.googleapis.com/auth/analytics.readonly')

@app.route('/my-page')
@decorator.oauth_required
def dashboard():
    pass

这将返回以下错误“AssertionError:视图函数映射正在覆盖现有端点函数:check_oauth”

然而,它在基本应用程序中运行良好:

class MyPage(webapp2.RequestHandler):
    @decorator.oauth_required
    def get(self):
        pass

app = webapp2.WSGIApplication([
    ('/my-page', MyPage),
    (decorator.callback_path, decorator.callback_handler())
], debug=True)

谢谢

0 个答案:

没有答案