Search code examples
django-allauthdjango-rest-auth

django rest auth - FacebookLogin view, missing 1 required positional argument 'request'


I'm following the django-rest-auth Social Authentication installation guide for Facebook, and have implemented the FacebookLogin class as a subclass of SocialLoginView, with adapter_class set to the FacebookOAuth2Adapter adapter, as per the install guide.

When I then post a request to /rest-auth/facebook I get the following error message "TypeError: init() missing 1 required positional argument: 'request' " from registration_serializers.py, line 63 (adapter = adapter_class() )

Am I missing a setting? Perhaps an allauth social setting somewhere? Thanks


Solution

  • This is a bug with django-rest-auth and django-allauth > 0.25.

    Workaround is to pass an init into the adapter, I've verified this works with my project.

    class FacebookOAuth2AdapterCustom(FacebookOAuth2Adapter):
        def __init__(self):
            pass
    
    class FacebookLogin(SocialLoginView):
        adapter_class = FacebookOAuth2AdapterCustom
    

    An issue with django-rest-auth has been submitted: https://github.com/Tivix/django-rest-auth/issues/197