1from allauth.socialaccount.providers.base import ProviderAccount
2from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
3
4
5class LineAccount(ProviderAccount):
6
7    def get_avatar_url(self):
8        return self.account.extra_data.get('pictureUrl')
9
10    def to_str(self):
11        return self.account.extra_data.get('displayName', self.account.uid)
12
13
14class LineProvider(OAuth2Provider):
15    id = 'line'
16    name = 'Line'
17    account_class = LineAccount
18
19    def get_default_scope(self):
20        return []
21
22    def extract_uid(self, data):
23        return str(data['userId'])
24
25    def extract_common_fields(self, data):
26        return dict(email=data.get('email'),
27                    username=data.get('displayName'),
28                    first_name=data.get('first_name'),
29                    last_name=data.get('last_name'),
30                    name=data.get('name'))
31
32
33provider_classes = [LineProvider]
34