Skip to content

Commit

Permalink
Raise an exception when the oauth flow fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mafrosis committed Jul 8, 2024
1 parent 952d2d0 commit 414cdf7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gcsa/_services/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from google.auth.transport.requests import Request
from google.auth.credentials import Credentials

from gcsa.exceptions import FailedToAuthenticateError


class AuthenticatedService:
"""Handles authentication of the `GoogleCalendar`"""
Expand Down Expand Up @@ -123,6 +125,9 @@ def _get_credentials(
except WSGITimeout:
print('Authentication flow timed out. Please try again.')

if credentials is None:
raise FailedToAuthenticateError

if save_token:
with open(token_path, 'wb') as token_file:
pickle.dump(credentials, token_file)
Expand Down
2 changes: 2 additions & 0 deletions gcsa/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class FailedToAuthenticateError(Exception):
pass

0 comments on commit 414cdf7

Please sign in to comment.