| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from allauth.socialaccount import providers |
| 4 |
from allauth.socialaccount.providers.base import ProviderAccount |
| 5 |
from allauth.socialaccount.providers.dropbox.views import DropboxOAuth2Adapter |
| 6 |
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider |
| 7 |
|
| 8 |
|
| 9 |
class DropboxOAuth2Account(ProviderAccount): |
| 10 |
pass |
| 11 |
|
| 12 |
|
| 13 |
class DropboxOAuth2Provider(OAuth2Provider): |
| 14 |
id = "dropbox" |
| 15 |
name = "Dropbox" |
| 16 |
account_class = DropboxOAuth2Account |
| 17 |
oauth2_adapter_class = DropboxOAuth2Adapter |
| 18 |
|
| 19 |
def extract_uid(self, data): |
| 20 |
return data["account_id"] |
| 21 |
|
| 22 |
def extract_common_fields(self, data): |
| 23 |
return dict(name=data["name"]["display_name"], email=data["email"]) |
| 24 |
|
| 25 |
|
| 26 |
providers.registry.register(DropboxOAuth2Provider) |