Debian Codegraph @

allauth/socialaccount/providers/instagram/provider.py

raw
1 from __future__ import annotations
2
3 from allauth.socialaccount.providers.base import ProviderAccount
4 from allauth.socialaccount.providers.instagram.views import InstagramOAuth2Adapter
5 from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
6
7
8 class InstagramAccount(ProviderAccount):
9 PROFILE_URL = "https://instagram.com/"
10
11 def get_profile_url(self):
12 username = self.account.extra_data.get("username")
13 return f"{self.PROFILE_URL}{username}"
14
15
16 class InstagramProvider(OAuth2Provider):
17 id = "instagram"
18 name = "Instagram"
19 account_class = InstagramAccount
20 oauth2_adapter_class = InstagramOAuth2Adapter
21
22 def extract_extra_data(self, data):
23 return data
24
25 def get_default_scope(self):
26 return ["user_profile"]
27
28 def extract_uid(self, data):
29 return str(data["id"])
30
31 def extract_common_fields(self, data):
32 return dict(username=data.get("username"))
33
34
35 provider_classes = [InstagramProvider]