Skip to content

Commit

Permalink
refactor(socialaccount): Provider.oauth2_adapter_class
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Mar 8, 2024
1 parent 13ad1ce commit a0d2db6
Show file tree
Hide file tree
Showing 210 changed files with 516 additions and 408 deletions.
2 changes: 2 additions & 0 deletions allauth/socialaccount/providers/agave/provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from allauth.socialaccount.providers.agave.views import AgaveAdapter
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -18,6 +19,7 @@ class AgaveProvider(OAuth2Provider):
id = "agave"
name = "Agave"
account_class = AgaveAccount
oauth2_adapter_class = AgaveAdapter

def extract_uid(self, data):
return str(data.get("create_time"))
Expand Down
3 changes: 1 addition & 2 deletions allauth/socialaccount/providers/agave/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from allauth.socialaccount import app_settings
from allauth.socialaccount.adapter import get_adapter
from allauth.socialaccount.providers.agave.provider import AgaveProvider
from allauth.socialaccount.providers.oauth2.views import (
OAuth2Adapter,
OAuth2CallbackView,
Expand All @@ -9,7 +8,7 @@


class AgaveAdapter(OAuth2Adapter):
provider_id = AgaveProvider.id
provider_id = "agave"

settings = app_settings.PROVIDERS.get(provider_id, {})
provider_base_url = settings.get("API_URL", "https://public.agaveapi.co")
Expand Down
2 changes: 2 additions & 0 deletions allauth/socialaccount/providers/amazon/provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from allauth.socialaccount.providers.amazon.views import AmazonOAuth2Adapter
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -11,6 +12,7 @@ class AmazonProvider(OAuth2Provider):
id = "amazon"
name = "Amazon"
account_class = AmazonAccount
oauth2_adapter_class = AmazonOAuth2Adapter

def get_default_scope(self):
return ["profile"]
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/amazon/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
OAuth2LoginView,
)

from .provider import AmazonProvider


class AmazonOAuth2Adapter(OAuth2Adapter):
provider_id = AmazonProvider.id
provider_id = "amazon"
access_token_url = "https://api.amazon.com/auth/o2/token"
authorize_url = "http://www.amazon.com/ap/oa"
profile_url = "https://api.amazon.com/user/profile"
Expand Down
4 changes: 4 additions & 0 deletions allauth/socialaccount/providers/amazon_cognito/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from allauth.socialaccount.providers.amazon_cognito.utils import (
convert_to_python_bool_if_value_is_json_string_bool,
)
from allauth.socialaccount.providers.amazon_cognito.views import (
AmazonCognitoOAuth2Adapter,
)
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -23,6 +26,7 @@ class AmazonCognitoProvider(OAuth2Provider):
id = "amazon_cognito"
name = "Amazon Cognito"
account_class = AmazonCognitoAccount
oauth2_adapter_class = AmazonCognitoOAuth2Adapter

def extract_uid(self, data):
return str(data["sub"])
Expand Down
5 changes: 1 addition & 4 deletions allauth/socialaccount/providers/amazon_cognito/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from allauth.socialaccount import app_settings
from allauth.socialaccount.adapter import get_adapter
from allauth.socialaccount.providers.amazon_cognito.provider import (
AmazonCognitoProvider,
)
from allauth.socialaccount.providers.oauth2.views import (
OAuth2Adapter,
OAuth2CallbackView,
Expand All @@ -11,7 +8,7 @@


class AmazonCognitoOAuth2Adapter(OAuth2Adapter):
provider_id = AmazonCognitoProvider.id
provider_id = "amazon_cognito"

DOMAIN_KEY_MISSING_ERROR = (
'"DOMAIN" key is missing in Amazon Cognito configuration.'
Expand Down
4 changes: 4 additions & 0 deletions allauth/socialaccount/providers/angellist/provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from allauth.socialaccount.providers.angellist.views import (
AngelListOAuth2Adapter,
)
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -18,6 +21,7 @@ class AngelListProvider(OAuth2Provider):
id = "angellist"
name = "AngelList"
account_class = AngelListAccount
oauth2_adapter_class = AngelListOAuth2Adapter

def extract_uid(self, data):
return str(data["id"])
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/angellist/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
OAuth2LoginView,
)

from .provider import AngelListProvider


class AngelListOAuth2Adapter(OAuth2Adapter):
provider_id = AngelListProvider.id
provider_id = "angellist"
access_token_url = "https://angel.co/api/oauth/token/"
authorize_url = "https://angel.co/api/oauth/authorize/"
profile_url = "https://api.angel.co/1/me/"
Expand Down
2 changes: 2 additions & 0 deletions allauth/socialaccount/providers/apple/provider.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from allauth.account.models import EmailAddress
from allauth.socialaccount.app_settings import QUERY_EMAIL
from allauth.socialaccount.providers.apple.views import AppleOAuth2Adapter
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -8,6 +9,7 @@ class AppleProvider(OAuth2Provider):
id = "apple"
name = "Apple"
account_class = ProviderAccount
oauth2_adapter_class = AppleOAuth2Adapter

def extract_uid(self, data):
return str(data["sub"])
Expand Down
3 changes: 1 addition & 2 deletions allauth/socialaccount/providers/apple/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@

from .apple_session import get_apple_session
from .client import AppleOAuth2Client
from .provider import AppleProvider


class AppleOAuth2Adapter(OAuth2Adapter):
client_class = AppleOAuth2Client
provider_id = AppleProvider.id
provider_id = "apple"
access_token_url = "https://appleid.apple.com/auth/token"
authorize_url = "https://appleid.apple.com/auth/authorize"
public_key_url = "https://appleid.apple.com/auth/keys"
Expand Down
2 changes: 2 additions & 0 deletions allauth/socialaccount/providers/asana/provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from allauth.socialaccount.providers.asana.views import AsanaOAuth2Adapter
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -10,6 +11,7 @@ class AsanaProvider(OAuth2Provider):
id = "asana"
name = "Asana"
account_class = AsanaAccount
oauth2_adapter_class = AsanaOAuth2Adapter

def extract_uid(self, data):
return str(data["id"])
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/asana/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
OAuth2LoginView,
)

from .provider import AsanaProvider


class AsanaOAuth2Adapter(OAuth2Adapter):
provider_id = AsanaProvider.id
provider_id = "asana"
access_token_url = "https://app.asana.com/-/oauth_token"
authorize_url = "https://app.asana.com/-/oauth_authorize"
profile_url = "https://app.asana.com/api/1.0/users/me"
Expand Down
3 changes: 2 additions & 1 deletion allauth/socialaccount/providers/auth0/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
from allauth.socialaccount.providers.auth0.views import Auth0OAuth2Adapter
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -16,6 +16,7 @@ class Auth0Provider(OAuth2Provider):
id = "auth0"
name = "Auth0"
account_class = Auth0Account
oauth2_adapter_class = Auth0OAuth2Adapter

def get_default_scope(self):
return ["openid", "profile", "email"]
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/auth0/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
from allauth.socialaccount import app_settings
from allauth.socialaccount.adapter import get_adapter
from allauth.socialaccount.providers.auth0.provider import Auth0Provider
from allauth.socialaccount.providers.oauth2.views import (
OAuth2Adapter,
OAuth2CallbackView,
Expand All @@ -10,7 +8,7 @@


class Auth0OAuth2Adapter(OAuth2Adapter):
provider_id = Auth0Provider.id
provider_id = "auth0"
supports_state = True

settings = app_settings.PROVIDERS.get(provider_id, {})
Expand Down
4 changes: 4 additions & 0 deletions allauth/socialaccount/providers/authentiq/provider.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from allauth.account.models import EmailAddress
from allauth.socialaccount import app_settings
from allauth.socialaccount.providers.authentiq.views import (
AuthentiqOAuth2Adapter,
)
from allauth.socialaccount.providers.base import AuthAction, ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand Down Expand Up @@ -56,6 +59,7 @@ class AuthentiqProvider(OAuth2Provider):
id = "authentiq"
name = "Authentiq"
account_class = AuthentiqAccount
oauth2_adapter_class = AuthentiqOAuth2Adapter

def get_scope(self, request):
scope = set(super(AuthentiqProvider, self).get_scope(request))
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/authentiq/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
OAuth2LoginView,
)

from .provider import AuthentiqProvider


class AuthentiqOAuth2Adapter(OAuth2Adapter):
provider_id = AuthentiqProvider.id
provider_id = "authentiq"

settings = app_settings.PROVIDERS.get(provider_id, {})

Expand Down
2 changes: 2 additions & 0 deletions allauth/socialaccount/providers/baidu/provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from allauth.socialaccount.providers.baidu.views import BaiduOAuth2Adapter
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider

Expand All @@ -21,6 +22,7 @@ class BaiduProvider(OAuth2Provider):
id = "baidu"
name = "Baidu"
account_class = BaiduAccount
oauth2_adapter_class = BaiduOAuth2Adapter

def extract_uid(self, data):
return data["uid"]
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/baidu/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
OAuth2LoginView,
)

from .provider import BaiduProvider


class BaiduOAuth2Adapter(OAuth2Adapter):
provider_id = BaiduProvider.id
provider_id = "baidu"
access_token_url = "https://openapi.baidu.com/oauth/2.0/token"
authorize_url = "https://openapi.baidu.com/oauth/2.0/authorize"
profile_url = (
Expand Down
4 changes: 4 additions & 0 deletions allauth/socialaccount/providers/basecamp/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.basecamp.views import (
BasecampOAuth2Adapter,
)
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider


Expand All @@ -15,6 +18,7 @@ class BasecampProvider(OAuth2Provider):
id = "basecamp"
name = "Basecamp"
account_class = BasecampAccount
oauth2_adapter_class = BasecampOAuth2Adapter

def get_auth_params(self, request, action):
data = super(BasecampProvider, self).get_auth_params(request, action)
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/basecamp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
OAuth2LoginView,
)

from .provider import BasecampProvider


class BasecampOAuth2Adapter(OAuth2Adapter):
provider_id = BasecampProvider.id
provider_id = "basecamp"
access_token_url = (
"https://launchpad.37signals.com/authorization/token?type=web_server" # noqa
)
Expand Down
4 changes: 4 additions & 0 deletions allauth/socialaccount/providers/battlenet/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.battlenet.views import (
BattleNetOAuth2Adapter,
)
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider


Expand All @@ -12,6 +15,7 @@ class BattleNetProvider(OAuth2Provider):
id = "battlenet"
name = "Battle.net"
account_class = BattleNetAccount
oauth2_adapter_class = BattleNetOAuth2Adapter

def extract_uid(self, data):
uid = str(data["id"])
Expand Down
5 changes: 2 additions & 3 deletions allauth/socialaccount/providers/battlenet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
OAuth2LoginView,
)

from .provider import BattleNetProvider


class Region:
APAC = "apac"
Expand Down Expand Up @@ -76,7 +74,8 @@ class BattleNetOAuth2Adapter(OAuth2Adapter):
Can be any of eu, us, kr, sea, tw or cn
"""

provider_id = BattleNetProvider.id
provider_id = "battlenet"

valid_regions = (
Region.APAC,
Region.CN,
Expand Down
4 changes: 4 additions & 0 deletions allauth/socialaccount/providers/bitbucket_oauth2/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.bitbucket_oauth2.views import (
BitbucketOAuth2Adapter,
)
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider


Expand All @@ -18,6 +21,7 @@ class BitbucketOAuth2Provider(OAuth2Provider):
id = "bitbucket_oauth2"
name = "Bitbucket"
account_class = BitbucketOAuth2Account
oauth2_adapter_class = BitbucketOAuth2Adapter

def extract_uid(self, data):
return data["username"]
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/bitbucket_oauth2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
OAuth2LoginView,
)

from .provider import BitbucketOAuth2Provider


class BitbucketOAuth2Adapter(OAuth2Adapter):
provider_id = BitbucketOAuth2Provider.id
provider_id = "bitbucket_oauth2"
access_token_url = "https://bitbucket.org/site/oauth2/access_token"
authorize_url = "https://bitbucket.org/site/oauth2/authorize"
profile_url = "https://api.bitbucket.org/2.0/user"
Expand Down
2 changes: 2 additions & 0 deletions allauth/socialaccount/providers/bitly/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.bitly.views import BitlyOAuth2Adapter
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider


Expand All @@ -21,6 +22,7 @@ class BitlyProvider(OAuth2Provider):
id = "bitly"
name = "Bitly"
account_class = BitlyAccount
oauth2_adapter_class = BitlyOAuth2Adapter

def extract_uid(self, data):
return str(data["login"])
Expand Down
4 changes: 1 addition & 3 deletions allauth/socialaccount/providers/bitly/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
OAuth2LoginView,
)

from .provider import BitlyProvider


class BitlyOAuth2Adapter(OAuth2Adapter):
provider_id = BitlyProvider.id
provider_id = "bitly"
access_token_url = "https://api-ssl.bitly.com/oauth/access_token"
authorize_url = "https://bitly.com/oauth/authorize"
profile_url = "https://api-ssl.bitly.com/v3/user/info"
Expand Down
2 changes: 2 additions & 0 deletions allauth/socialaccount/providers/box/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.box.views import BoxOAuth2Adapter
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider


Expand All @@ -10,6 +11,7 @@ class BoxOAuth2Provider(OAuth2Provider):
id = "box"
name = "Box"
account_class = BoxOAuth2Account
oauth2_adapter_class = BoxOAuth2Adapter

def extract_uid(self, data):
return data["id"]
Expand Down

0 comments on commit a0d2db6

Please sign in to comment.