2016-05-14 124 views
0

我有一個應用程序,其中有一個客戶端ID some_client_id用戶通過Facebook oauth進行身份驗證。返回的令牌(代碼)是some_token_to_auth_the_user用appid和訪問令牌驗證django rest框架?

我的後端是django rest frameworkrest_auth

我現在想對URL http://localhost.com:8000/rest-auth/facebook/enter image description here

哪些憑證輸入驗證形式與facebook code (token)

用戶?

client-idfacebook-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 

我究竟做錯了什麼?感謝您的任何幫助。

回答

0

Facebook SDK提供了一個Login function

它返回的authResponseaccess_token以及code。你需要POST這些到Django-rest-auth端點,這將通過Facebook驗證用戶。

相關問題