AssertionError:未设置请求全局变量

时间:2014-04-13 14:48:38

标签: python google-app-engine webapp2

我知道这是一个重复的问题但是通过参考之前的答案,我还没有找到解决方案。

我使用Google报告API来获取日志。 请参阅此链接:https://developers.google.com/admin-sdk/reports/v1/libraries

一切顺利,我可以使用范围,客户端ID等生成授权URL。 但我无法将用户重定向到URL以从授权URL获取“代码”。

我尝试使用webapp2脚本但抛出错误= AssertionError:未设置请求全局变量。

以下是我用于重定向的代码:

import webapp2


class MainPage(webapp2.RequestHandler):

    def get(self):
        import ipdb;ipdb.set_trace()
        path='my authorize url path'
        return self.redirect(path) #throws error on this line


a1=MainPage() #object to call class

a2=a1.get() #call method of class

我哪里错了?如果webapp2具有self.redirect的标准错误,那么哪个其他框架可以帮助执行相同的操作?

如果我使用app = webapp2.WSGIApplication([('/', MainPage)])而不是创建对象,那么它甚至不会调用get(self)函数。 任何帮助,将不胜感激。 感谢。

0 个答案:

没有答案
相关问题