iMerica / dj-rest-auth

Authentication for Django Rest Framework

Home Page:https://dj-rest-auth.readthedocs.io/en/latest/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Social login: GET method not supported

jonasN5 opened this issue · comments

Login with Twitch doesn't work because the callback with the authorization code is a GET request, which raises:
django all auth save() prohibited to prevent data loss due to unsaved related object 'app'.

I patched it like so:

class TwitchLogin(SocialLoginView):
    adapter_class = TwitchOAuth2Adapter
    # callback_url = 'http://127.0.0.1:8080/accounts/twitch/login/callback/'
    callback_url = 'http://localhost:8080/accounts/twitch/'
    client_class = OAuth2Client

    def get(self, request, *args, **kwargs):
        request.data['code'] = request.query_params['code']
        return self.post(request, *args, **kwargs)

Still, GET requests should be supported.