Skip to content

Commit

Permalink
util inspect-auth: fix unauthenticated case to print the right message
Browse files Browse the repository at this point in the history
Fixes minor bug in #780.
  • Loading branch information
dbarnett committed Sep 26, 2024
1 parent bcda636 commit 052b230
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gcalcli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def main():
auth_data = utils.inspect_auth()
for k, v in auth_data.items():
printer.msg(f"{k}: {v}\n")
if 'format' in auth_data:
if auth_data.get('format', 'unknown') != 'unknown':
printer.msg(
"\n"
"The grant's entry under "
Expand Down
3 changes: 1 addition & 2 deletions gcalcli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def inspect_auth() -> dict[str, Any]:
auth_data['format'] = 'json'
except (OSError, ValueError, EOFError):
pass
auth_data.setdefault('format', 'unknown')
if 'format' in auth_data:
for k in [
'client_id',
Expand All @@ -268,6 +269,4 @@ def inspect_auth() -> dict[str, Any]:
]:
if hasattr(creds, k):
auth_data[k] = getattr(creds, k)
else:
auth_data['format'] = 'unknown'
return auth_data

0 comments on commit 052b230

Please sign in to comment.