AttributeError: 'WSGIRequest' 对象在 OAuth2Decorator 上没有属性 'request'



我在谷歌应用引擎上使用Django试图访问谷歌API时遇到了一个问题。

我想使用decorator,如文档中所述,但我一次又一次地收到相同的错误:

AttributeError: 'WSGIRequest' object has no attribute 'request'

和StackTrace:

Internal Server Error: /
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.5/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/Users/johannes/GitHub/itzehoe/dependencies/oauth2client/appengine.py", line 703, in check_oauth
self._create_flow(request_handler)
File "/Users/johannes/GitHub/itzehoe/dependencies/oauth2client/appengine.py", line 734, in _create_flow
redirect_uri = request_handler.request.relative_url(
AttributeError: 'WSGIRequest' object has no attribute 'request'

还有一些代码:

from google.appengine.api import users
from oauth2client.appengine import OAuth2DecoratorFromClientSecrets
from django.shortcuts import render
from django.conf import settings
decorator = OAuth2DecoratorFromClientSecrets(settings.GOOGLE_CLIENT_SECRETS,
'https://www.googleapis.com/auth/admin.directory.group')

@decorator.oauth_required
def index(request):
context = {}
return render(request, 'index.html', context)

OAuth2Decorator功能假设您正在将方法包装在webappwebapp2RequestHandler子类中,它不是为处理django视图而设计的。

相关内容

  • 没有找到相关文章

最新更新