开发者

CSRF verification failed, but only with Facebook App

开发者 https://www.devze.com 2023-02-04 06:57 出处:网络
I am creating a Facebook App using Django. When I access my webpage directly then it works fine. I have then added this webpage as the Facebook canvas URL, so that users are directed to this page wh

I am creating a Facebook App using Django.

When I access my webpage directly then it works fine. I have then added this webpage as the Facebook canvas URL, so that users are directed to this page when they go to the App. Now, when I enter the App, I get the "CSRF verification failed" error. I think it's because facebook is doing a POST, but without the CSRF token. However, I cannot control how Facebook redirects to my App.

Anyone know how to deal with this?

This is all my View does:

def frontpage(request):
开发者_开发技巧    return render_to_response('tube/frontpage.html', {"s": 'hello'})

and frontpage.html just writes "front page!"


I figured it out:

from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def my_view(request):
    return HttpResponse('Hello world')
0

精彩评论

暂无评论...
验证码 换一张
取 消