Debian Codegraph @

allauth/socialaccount/providers/line/provider.py

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