| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from allauth.socialaccount.providers.base import ProviderAccount |
| 4 |
from allauth.socialaccount.providers.feishu.views import FeishuOAuth2Adapter |
| 5 |
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider |
| 6 |
|
| 7 |
|
| 8 |
class FeishuAccount(ProviderAccount): |
| 9 |
def get_avatar_url(self): |
| 10 |
return self.account.extra_data.get("avatar_big") |
| 11 |
|
| 12 |
|
| 13 |
class FeishuProvider(OAuth2Provider): |
| 14 |
id = "feishu" |
| 15 |
name = "feishu" |
| 16 |
account_class = FeishuAccount |
| 17 |
oauth2_adapter_class = FeishuOAuth2Adapter |
| 18 |
|
| 19 |
def extract_uid(self, data): |
| 20 |
return data["open_id"] |
| 21 |
|
| 22 |
def extract_common_fields(self, data): |
| 23 |
return dict(username=data.get("name"), name=data.get("name")) |
| 24 |
|
| 25 |
|
| 26 |
provider_classes = [FeishuProvider] |