Debian Codegraph @

allauth/socialaccount/providers/drip/provider.py

raw
1 from __future__ import annotations
2
3 from allauth.account.models import EmailAddress
4 from allauth.socialaccount.providers.base import ProviderAccount
5 from allauth.socialaccount.providers.drip.views import DripOAuth2Adapter
6 from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
7
8
9 class DripAccount(ProviderAccount):
10 pass
11
12
13 class DripProvider(OAuth2Provider):
14 id = "drip"
15 name = "Drip"
16 account_class = DripAccount
17 oauth2_adapter_class = DripOAuth2Adapter
18
19 def extract_uid(self, data):
20 # no uid available, we generate one by hashing the email
21 uid = hash(data.get("email"))
22 return str(uid)
23
24 def extract_common_fields(self, data):
25 return dict(email=data.get("email"), name=data.get("name"))
26
27 def extract_email_addresses(self, data):
28 ret = []
29 email = data.get("email")
30 if email:
31 ret.append(EmailAddress(email=email, verified=True, primary=True))
32 return ret
33
34
35 provider_classes = [DripProvider]