Skip to content

Commit 509cb35

Browse files
authored
Merge pull request #618 from bijanvakili/fix-issue-605
Fix issue #605: Use Credentials.tojson() to serialize credentials
2 parents 9ba1a6d + 96a1128 commit 509cb35

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

pygsheets/authorization.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,9 @@ def _get_user_authentication_credentials(client_secret_file, scopes, credential_
6363
credentials = _get_initial_user_authentication_credentials(client_secret_file, local, scopes)
6464

6565
# Save the credentials for the next run
66-
credentials_as_dict = {
67-
'token': credentials.token,
68-
'refresh_token': credentials.refresh_token,
69-
'id_token': credentials.id_token,
70-
'token_uri': credentials.token_uri,
71-
'client_id': credentials.client_id,
72-
'client_secret': credentials.client_secret
73-
}
7466
try:
75-
with open(credentials_path, 'w') as file:
76-
file.write(json.dumps(credentials_as_dict))
67+
with open(credentials_path, mode='w') as file:
68+
file.write(credentials.to_json())
7769
except OSError:
7870
print("Unable to save the credentials to file-system")
7971

0 commit comments

Comments
 (0)