Reputation:
I am trying to create API and I'm wondering how I can create an endpoint for authenticating via Gmail account. Seems like django-rest-auth
supports only Facebook and Twitter.
Anyone could give me tips?
Upvotes: 1
Views: 541
Reputation: 1203
I am using Django rest auth in one of my projects and it does support Google sign-in.
It supports all the social provider which django-allauth
supports.
Here is the list of the supported social provider by django-allauth and django-rest-auth
# social_auth_view.py
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from rest_auth.registration.views import SocialLoginView
class GoogleLogin(SocialLoginView):
adapter_class = GoogleOAuth2Adapter
# urls.py
urlpatterns += [
...,
url(r'^rest-auth/google/$', GoogleLogin.as_view(), name='google_login')
]
So, If you want to support any other social provider.
allauth.socialaccount.providers
.rest_auth.registration.views.SocialLoginView
.adapter_class
attribute.Upvotes: 1