This commit is contained in:
parent
1de1cb4086
commit
72ae2320d1
8 changed files with 34 additions and 6 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import requests
|
||||
from allauth.socialaccount import app_settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from allauth.socialaccount.providers.oauth2.views import (
|
||||
OAuth2Adapter,
|
||||
OAuth2CallbackView,
|
||||
|
|
@ -31,7 +32,12 @@ class OAuthAdapter(OAuth2Adapter):
|
|||
|
||||
@property
|
||||
def domain(self):
|
||||
return self.settings.get("DOMAIN", "")
|
||||
domain = self.settings.get("DOMAIN", "")
|
||||
if not domain:
|
||||
raise ImproperlyConfigured(
|
||||
"OAUTH_SERVER_URL is not configured. Set it in your .env file."
|
||||
)
|
||||
return domain
|
||||
|
||||
@property
|
||||
def access_token_url(self):
|
||||
|
|
@ -46,5 +52,7 @@ class OAuthAdapter(OAuth2Adapter):
|
|||
return f"https://{self.domain}/api/me/"
|
||||
|
||||
|
||||
OAuthProvider.oauth2_adapter_class = OAuthAdapter
|
||||
|
||||
oauth2_login = OAuth2LoginView.adapter_view(OAuthAdapter)
|
||||
oauth2_callback = OAuth2CallbackView.adapter_view(OAuthAdapter)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue