| 1 |
""" |
| 2 |
from __future__ import annotations |
| 3 |
|
| 4 |
Provider for Patreon |
| 5 |
""" |
| 6 |
|
| 7 |
from allauth.socialaccount.providers.base import ProviderAccount |
| 8 |
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider |
| 9 |
from allauth.socialaccount.providers.vimeo_oauth2.views import VimeoOAuth2Adapter |
| 10 |
|
| 11 |
|
| 12 |
class VimeoOAuth2Account(ProviderAccount): |
| 13 |
pass |
| 14 |
|
| 15 |
|
| 16 |
class VimeoOAuth2Provider(OAuth2Provider): |
| 17 |
id = "vimeo_oauth2" |
| 18 |
name = "Vimeo" |
| 19 |
account_class = VimeoOAuth2Account |
| 20 |
oauth2_adapter_class = VimeoOAuth2Adapter |
| 21 |
|
| 22 |
def get_default_scope(self): |
| 23 |
return ["public", "private"] |
| 24 |
|
| 25 |
def extract_uid(self, data): |
| 26 |
return data.get("uri").split("/")[-1] |
| 27 |
|
| 28 |
def extract_common_fields(self, data): |
| 29 |
return { |
| 30 |
"fullname": data.get("name"), |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
provider_classes = [VimeoOAuth2Provider] |