用appid和访问令牌验证django rest框架?
问题描述:
我有一个应用程序,其中有一个客户端ID some_client_id
用户通过Facebook oauth进行身份验证。返回的令牌(代码)是some_token_to_auth_the_user
。用appid和访问令牌验证django rest框架?
我的后端是django rest framework
和rest_auth
。
我现在想对URL http://localhost.com:8000/rest-auth/facebook/
哪些凭证输入验证形式与facebook code (token)
用户?
是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
我究竟做错了什么?感谢您的任何帮助。
答
Facebook SDK提供了一个Login function。
它返回的authResponse
有access_token
以及code
。你需要POST
这些到Django-rest-auth
端点,这将通过Facebook验证用户。