Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(oauth): show an informative log when OAuthError is raise #3392

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions allauth/socialaccount/providers/oauth/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ def _get_request_token(self):
response = requests.post(url=rt_url, auth=oauth)
if response.status_code not in [200, 201]:
raise OAuthError(
_("Invalid response while obtaining request token" ' from "%s".')
% get_token_prefix(self.request_token_url)
_(
"Invalid response while obtaining request token"
' from "%s". Response was: %s.'
)
% (get_token_prefix(self.request_token_url), response.text)
)
self.request_token = dict(parse_qsl(response.text))
self.request.session[
Expand Down
6 changes: 6 additions & 0 deletions allauth/socialaccount/providers/oauth/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import

import logging

from django.urls import reverse

from allauth.socialaccount.adapter import get_adapter
Expand All @@ -19,6 +21,9 @@
)


logger = logging.getLogger(__name__)


class OAuthAdapter(object):
def __init__(self, request):
self.request = request
Expand Down Expand Up @@ -78,6 +83,7 @@ def login(self, request, *args, **kwargs):
try:
return client.get_redirect(auth_url, auth_params)
except OAuthError as e:
logger.error("OAuth authentication error", exc_info=True)
return render_authentication_error(
request, self.adapter.provider_id, exception=e
)
Expand Down