| 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.soundcloud.views import SoundCloudOAuth2Adapter |
| 6 |
|
| 7 |
|
| 8 |
class SoundCloudAccount(ProviderAccount): |
| 9 |
def get_profile_url(self): |
| 10 |
return self.account.extra_data.get("permalink_url") |
| 11 |
|
| 12 |
def get_avatar_url(self): |
| 13 |
return self.account.extra_data.get("avatar_url") |
| 14 |
|
| 15 |
|
| 16 |
class SoundCloudProvider(OAuth2Provider): |
| 17 |
id = "soundcloud" |
| 18 |
name = "SoundCloud" |
| 19 |
account_class = SoundCloudAccount |
| 20 |
oauth2_adapter_class = SoundCloudOAuth2Adapter |
| 21 |
|
| 22 |
def extract_uid(self, data): |
| 23 |
return str(data["urn"]) |
| 24 |
|
| 25 |
def extract_common_fields(self, data): |
| 26 |
return dict( |
| 27 |
name=data.get("full_name"), |
| 28 |
username=data.get("username"), |
| 29 |
email=data.get("email"), |
| 30 |
) |
| 31 |
|
| 32 |
|
| 33 |
provider_classes = [SoundCloudProvider] |