Debian Codegraph @

allauth/socialaccount/providers/paypal/provider.py

raw
1 from __future__ import annotations
2
3 from allauth.socialaccount.providers.base import ProviderAccount
4 from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
5 from allauth.socialaccount.providers.paypal.views import PaypalOAuth2Adapter
6
7
8 class PaypalAccount(ProviderAccount):
9 def get_avatar_url(self):
10 return self.account.extra_data.get("picture")
11
12
13 class PaypalProvider(OAuth2Provider):
14 id = "paypal"
15 name = "Paypal"
16 account_class = PaypalAccount
17 oauth2_adapter_class = PaypalOAuth2Adapter
18
19 def get_default_scope(self):
20 # See: https://developer.paypal.com/docs/integration/direct/identity/attributes/ # noqa
21 return ["openid", "email"]
22
23 def extract_uid(self, data):
24 return str(data["user_id"])
25
26 def extract_common_fields(self, data):
27 # See: https://developer.paypal.com/docs/api/#get-user-information
28 return dict(
29 first_name=data.get("given_name", ""),
30 last_name=data.get("family_name", ""),
31 email=data.get("email"),
32 )
33
34
35 provider_classes = [PaypalProvider]