From 0cb372faddb14e5e4708024299ec2fc879e1e62d Mon Sep 17 00:00:00 2001 From: "Alexey Evseev @stalk" Date: Sat, 18 Apr 2020 23:01:52 +0300 Subject: [PATCH] Take provider name from URL first [fixes #121] --- README.md | 5 ++++- rest_social_auth/views.py | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a6a29a1..885e52a 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ Quick start This redirect_uri must be equal in front-end request and in back-end request. Back-end will not do any redirect in fact. - It is also possible to specify provider in url, not in request body. + It is also possible to specify provider in URL, not in request body. Just append it to the url: POST /api/login/social/session/facebook/ @@ -255,6 +255,9 @@ Quick start "code": "AQBPBBTjbdnehj51" } + Provider defined in URL has higher priority than provider in body. + If both are specified - provider will be taken from URL. + OAuth 2.0 workflow with rest-social-auth ----------------------------------------- diff --git a/rest_social_auth/views.py b/rest_social_auth/views.py index 758ab47..28bb2df 100644 --- a/rest_social_auth/views.py +++ b/rest_social_auth/views.py @@ -213,10 +213,9 @@ def get_redirect_uri(self, manual_redirect_uri): return manual_redirect_uri def get_provider_name(self, input_data): - if 'provider' in input_data: - return input_data['provider'] - else: - return self.kwargs.get('provider') + if self.kwargs.get('provider'): + return self.kwargs['provider'] + return input_data.get('provider') def respond_error(self, error): if isinstance(error, Exception):