iMerica / dj-rest-auth

Authentication for Django Rest Framework
https://dj-rest-auth.readthedocs.io/en/latest/index.html
MIT License
1.62k stars 302 forks source link

Social login: GET method not supported #598

Open jonasN5 opened 3 months ago

jonasN5 commented 3 months ago

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.