From 370d91f5d2a11fde9be15a00f45b4a010fdfe91b Mon Sep 17 00:00:00 2001 From: Priya Dhoundiyal Date: Mon, 5 Mar 2018 19:23:13 +0530 Subject: [PATCH] fix(linkedin): Use HTTP response code Similar to https://github.com/pennersr/django-allauth/commit/8705514dc164577f801cdacb5c46623c8cb9909b but for LinkedIn - If LinkedIn responds with a 401 in case of an invalid token, raise an `HTTPError` (resp.raise_for_status) to handle the exception correctly instead of the current Http500 status because of a `KeyError`. --- allauth/socialaccount/providers/linkedin_oauth2/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/allauth/socialaccount/providers/linkedin_oauth2/views.py b/allauth/socialaccount/providers/linkedin_oauth2/views.py index 8088e4a6a6..c47db8001c 100644 --- a/allauth/socialaccount/providers/linkedin_oauth2/views.py +++ b/allauth/socialaccount/providers/linkedin_oauth2/views.py @@ -27,6 +27,7 @@ def get_user_info(self, token): fields = self.get_provider().get_profile_fields() url = self.profile_url + ':(%s)?format=json' % ','.join(fields) resp = requests.get(url, params={'oauth2_access_token': token.token}) + resp.raise_for_status() return resp.json()