使用appid和访问令牌验证django rest框架?

时间:2016-05-14 02:54:02

标签: django oauth-2.0 django-rest-framework django-rest-auth

我有一个应用,其客户端ID为some_client_id,用户通过Facebook oauth进行身份验证。返回的令牌(代码)是some_token_to_auth_the_user

我的后端是django rest frameworkrest_auth

现在我正尝试使用facebook code (token)

对用户进行身份验证 网址http://localhost.com:8000/rest-auth/facebook/ enter image description here

上的

输入表单的凭据是什么?

client-id还是facebook-token

我试过两个,

输出是,

TypeError at /rest-auth/facebook/
__init__() takes exactly 2 arguments (1 given)
Request Method: POST
Request URL:    http://localhost.com:8000/rest-auth/facebook/
Django Version: 1.9.6
Exception Type: TypeError
Exception Value:    
__init__() takes exactly 2 arguments (1 given)
Exception Location: /home/xo/.virtualenvs/dj19/local/lib/python2.7/site-packages/rest_auth/registration/serializers.py in validate, line 63
Python Executable:  /home/xo/.virtualenvs/dj19/bin/python
Python Version: 2.7.10

这些是观点,

from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
from rest_auth.registration.views import SocialLoginView
from allauth.socialaccount.providers.twitter.views import TwitterOAuthAdapter
from rest_auth.views import LoginView
from rest_auth.social_serializers import TwitterLoginSerializer


class FacebookLogin(SocialLoginView):
    adapter_class = FacebookOAuth2Adapter


class TwitterLogin(LoginView):
    serializer_class = TwitterLoginSerializer
    adapter_class = TwitterOAuthAdapter
我做错了什么?谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

Facebook SDK提供Login function

返回up/home let someVC = self.storyboard!.instantiateViewControllerWithIdentifier("something") as! SomethingViewController 以及authResponse。您需要access_token这些code端点,这将通过Facebook对用户进行身份验证。