Skip to content

Commit ff9db2d

Browse files
committed
Raise an exception when the oauth flow fails
1 parent 952d2d0 commit ff9db2d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

gcsa/_services/authentication.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from google.auth.transport.requests import Request
1010
from google.auth.credentials import Credentials
1111

12+
from gcsa.exceptions import FailedToAuthenticateError
13+
1214

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

128+
if credentials is None:
129+
raise FailedToAuthenticateError
130+
126131
if save_token:
127132
with open(token_path, 'wb') as token_file:
128133
pickle.dump(credentials, token_file)

gcsa/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class FailedToAuthenticateError(Exception):
2+
'Failed to authenticate to the Google API'

0 commit comments

Comments
 (0)