Why django-rest-auth SocialLoginView is not working?

Viewed 1378

https://django-rest-auth.readthedocs.io/en/latest/installation.html here is the official docs about social login in django-rest-auth. they say the way to make the LoginView(GithubLogin, FacebookLogin, etc..) inheriting SocialLoginView like this.

from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
from rest_auth.registration.views import SocialLoginView

class GithubLogin(SocialLoginView):
    adapter_class = GitHubOAuth2Adapter
    callback_url = CALLBACK_URL_YOU_SET_ON_GITHUB
    client_class = OAuth2Client

but when i try to access the url with this as as.view(), they always say

{
    "non_field_errors": [
        "View is not defined, pass it as a context variable"
    ]
}

I tried the best. I have been suffering it for a few days. plz anybody save my life.. What's wrong with it? I've searched a lots but there wasn't any good answer for me.

1 Answers

So I've done a little digging and I discovered the problem.

The django-rest-auth package is no longer maintained and thus does not support modern versions of django rest framework. At the time of this post, up to version 3.10.3 of DRF is verified to work and I can verify that version 3.12.1 (and presumably onward) does not.

It looks like the project has been forked to dj-rest-auth and is receiving further support there. I would recommend migrating to that package.

You can read more about the decision to stop maintenance and fork to a new repository here.

Related