From 8828380b83ea32fabff55fc909a2172c5f2da92a Mon Sep 17 00:00:00 2001 From: Johnny Chang Date: Thu, 14 Feb 2019 21:26:32 +0800 Subject: [PATCH] fix(line): updated LINE api version --- allauth/socialaccount/providers/line/provider.py | 9 ++++++++- allauth/socialaccount/providers/line/tests.py | 2 +- allauth/socialaccount/providers/line/views.py | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/allauth/socialaccount/providers/line/provider.py b/allauth/socialaccount/providers/line/provider.py index 495ebb6896..a915a607ef 100644 --- a/allauth/socialaccount/providers/line/provider.py +++ b/allauth/socialaccount/providers/line/provider.py @@ -20,7 +20,14 @@ def get_default_scope(self): return [] def extract_uid(self, data): - return str(data['mid']) + return str(data['userId']) + + def extract_common_fields(self, data): + return dict(email=data.get('email'), + username=data.get('displayName'), + first_name=data.get('first_name'), + last_name=data.get('last_name'), + name=data.get('name')) provider_classes = [LineProvider] diff --git a/allauth/socialaccount/providers/line/tests.py b/allauth/socialaccount/providers/line/tests.py index 2b5f9369ee..7e7cc188e9 100644 --- a/allauth/socialaccount/providers/line/tests.py +++ b/allauth/socialaccount/providers/line/tests.py @@ -10,7 +10,7 @@ class LineTests(OAuth2TestsMixin, TestCase): def get_mocked_response(self): return MockedResponse(200, """ { -"mid": "u7d47d26a6bab09b95695ff02d1a36e38", +"userId": "u7d47d26a6bab09b95695ff02d1a36e38", "displayName": "\uc774\uc0c1\ud601", "pictureUrl": "http://dl.profile.line-cdn.net/0m055ab14d725138288331268c45ac5286a35482fb794a" diff --git a/allauth/socialaccount/providers/line/views.py b/allauth/socialaccount/providers/line/views.py index 4804daf685..8ac9977e45 100644 --- a/allauth/socialaccount/providers/line/views.py +++ b/allauth/socialaccount/providers/line/views.py @@ -11,9 +11,9 @@ class LineOAuth2Adapter(OAuth2Adapter): provider_id = LineProvider.id - access_token_url = 'https://api.line.me/v1/oauth/accessToken' - authorize_url = 'https://access.line.me/dialog/oauth/weblogin' - profile_url = 'https://api.line.me/v1/profile' + access_token_url = 'https://api.line.me/oauth2/v2.1/token' + authorize_url = 'https://access.line.me/oauth2/v2.1/authorize' + profile_url = 'https://api.line.me/v2/profile' def complete_login(self, request, app, token, **kwargs): headers = {'Authorization': 'Bearer {0}'.format(token.token)}