我使用以下设置首先对用户进行身份验证,然后使用身份验证信息处理以下请求。
来自views.py
@canvas_only
def authenticate(request):
request.session['access_token'] = request.facebook.graph.access_token
return render(request, 'authenticated.html', {})
class Home(View):
def get(self, request, *args, **kwargs):
"""The home to be called from within the application"""
access_token = request.session['access_token']
graph = facebook.GraphAPI(access_token)
me = graph.get_object('me')
request.session['my_id'] = me['id']
template_data = _collect_home_data(graph)
return render(request, 'home.html', template_data)
来自 urls.py:
urlpatterns = patterns('',
url(r'^$', 'crosswords.ugly.views.authenticate'),
url(r'^home/$', Home.as_view(), name='home'),
这主要工作(应用程序内的链接现在可以正常工作)但新用户(尚未授权应用程序)收到以下错误消息:
填字游戏出现错误。请稍后再试。
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.
facebook 上的应用程序设置(画布 url、安全画布 url)都指向
http(s)://finebitstrings.pythonanywhere.com/
我能做些什么来摆脱这个错误?