| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from allauth.socialaccount.providers.base import ProviderAccount |
| 4 |
from allauth.socialaccount.providers.box.views import BoxOAuth2Adapter |
| 5 |
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider |
| 6 |
|
| 7 |
|
| 8 |
class BoxOAuth2Account(ProviderAccount): |
| 9 |
pass |
| 10 |
|
| 11 |
|
| 12 |
class BoxOAuth2Provider(OAuth2Provider): |
| 13 |
id = "box" |
| 14 |
name = "Box" |
| 15 |
account_class = BoxOAuth2Account |
| 16 |
oauth2_adapter_class = BoxOAuth2Adapter |
| 17 |
|
| 18 |
def extract_uid(self, data): |
| 19 |
return data["id"] |
| 20 |
|
| 21 |
def extract_common_fields(self, data): |
| 22 |
return dict(name=data.get("display_name"), email=data.get("email")) |
| 23 |
|
| 24 |
|
| 25 |
provider_classes = [BoxOAuth2Provider] |