-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
provider.py
36 lines (26 loc) · 1.11 KB
/
provider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from allauth.socialaccount import providers
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
class EdmodoAccount(ProviderAccount):
def get_profile_url(self):
return self.account.extra_data.get('profile_url')
def get_avatar_url(self):
return self.account.extra_data.get('avatar_url')
class EdmodoProvider(OAuth2Provider):
id = 'edmodo'
name = 'Edmodo'
package = 'allauth.socialaccount.providers.edmodo'
account_class = EdmodoAccount
def get_default_scope(self):
return ['basic']
def extract_uid(self, data):
return str(data['id'])
def extract_common_fields(self, data):
return dict(first_name=data.get('first_name'),
last_name=data.get('last_name'),
email=data.get('email', ''))
def extract_extra_data(self, data):
return dict(user_type=data.get('type'),
profile_url=data.get('url'),
avatar_url=data.get('avatars').get('large'))
providers.registry.register(EdmodoProvider)