Skip to content

Commit

Permalink
chore(oauth): show an informative log when OAuthError is raised
Browse files Browse the repository at this point in the history
Co-authored-by: varun kumar <varun.kumar@zenatix.com>
  • Loading branch information
varunsaral and varun kumar authored Aug 29, 2023
1 parent 336ebf1 commit 437cb65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit 437cb65

Please sign in to comment.