| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from allauth.socialaccount.providers.base import ProviderAccount |
| 4 |
from allauth.socialaccount.providers.coinbase.views import CoinbaseOAuth2Adapter |
| 5 |
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider |
| 6 |
|
| 7 |
|
| 8 |
class CoinbaseAccount(ProviderAccount): |
| 9 |
def get_avatar_url(self): |
| 10 |
return None |
| 11 |
|
| 12 |
|
| 13 |
class CoinbaseProvider(OAuth2Provider): |
| 14 |
id = "coinbase" |
| 15 |
name = "Coinbase" |
| 16 |
account_class = CoinbaseAccount |
| 17 |
oauth2_adapter_class = CoinbaseOAuth2Adapter |
| 18 |
|
| 19 |
def get_default_scope(self): |
| 20 |
# See: https://coinbase.com/docs/api/permissions |
| 21 |
return ["wallet:user:email"] |
| 22 |
|
| 23 |
def extract_uid(self, data): |
| 24 |
return str(data["id"]) |
| 25 |
|
| 26 |
def extract_common_fields(self, data): |
| 27 |
# See: https://coinbase.com/api/doc/1.0/users/index.html |
| 28 |
return dict(email=data["email"]) |
| 29 |
|
| 30 |
|
| 31 |
provider_classes = [CoinbaseProvider] |