Alrighty。设置信息 - Django 1.8.3,Python 2.7.3,使用Goodreads 0.2.4 api处理程序(略微修改)。我正处于Goodreads对应用程序进行回调的地步,但是clickjacker中间件将其作为一个错误捕获并扔掉了404.如果我禁用了clickjacker预防(我不想这样做),我得到了“类型'类型的参数'不可迭代”错误。
相关守则:
from goodreads import client
grClient = client.GoodreadsClient(<key>,<other_key>)
def goodReadsOAUTH_stage1(request,user):
try:
return HttpResponseRedirect(grClient.authenticate())
# function modified to return the URL rather than open a browser
except keyError:
return Http404
def goodReadsOAUTH_stage2(request):
if request.method == "GET":
if request.GET['authorize'] == 1:
grRecord = goodreadsOAUTHKeys(request.user,request.GET['oauth_token']
grRecord.save()
grClient.session.oauth_finalize()
return HttpResponseRedirect(reverse(request,'workroom:profile',kwargs={'user':request.user.username}))
else:
return Http404
else:
return Http404
两者的URLconf:
url(r'^social/(?P<user>[-\w\d]+)/goodreads/OAUTH/$', views.goodReadsOAUTH_stage1, name='goodreads-oauth-one'),
url(r'^social/goodreads/OAUTH/validation/$', views.goodReadsOAUTH_stage2, name='goodreads-oauth-two'),
随后出现错误信息!
类型对象'Http404'没有属性'get'
异常位置:/ home /.../public/env/local/lib/python2.7/site-packages/django/middleware/clickjacking.py in process_response,第31行
来自点击劫持保护的那一行代码:
if response.get('X-Frame-Options', None) is not None:
对于如何使回调正常运行,我基本上处于亏损状态。
答案 0 :(得分:1)