Skip to content

Commit f438f5a

Browse files
committed
Modify invalid exception error to be less cryptic and give more context
to the developer. This is to fix my personal debugging experience when trying to debug the fact that I had downloaded the wrong client secret JSON type (not web/installed).
1 parent f85d673 commit f438f5a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

oauth2client/clientsecrets.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,18 @@ class InvalidClientSecretsError(Error):
6969

7070

7171
def _validate_clientsecrets(obj):
72-
if obj is None or len(obj) != 1:
73-
raise InvalidClientSecretsError('Invalid file format.')
72+
_INVALID_FILE_FORMAT_MSG = (
73+
'Invalid file format. See '
74+
'https://developers.google.com/api-client-library/'
75+
'python/guide/aaa_client_secrets')
76+
77+
if obj is None:
78+
raise InvalidClientSecretsError(_INVALID_FILE_FORMAT_MSG)
79+
if len(obj) != 1:
80+
raise InvalidClientSecretsError(
81+
_INVALID_FILE_FORMAT_MSG + ' '
82+
'Expected a JSON object with a single property for a "web" or '
83+
'"installed" application')
7484
client_type = tuple(obj)[0]
7585
if client_type not in VALID_CLIENT:
7686
raise InvalidClientSecretsError('Unknown client type: %s.' % (client_type,))

0 commit comments

Comments
 (0)