- with open(TOKEN_FILE, 'wb') as token:
- pickle.dump(creds, token)
-
- print("Token now saved in {}".format(TOKEN_FILE))
+ with open(TOKEN_FILE, 'wb') as token_file:
+ creds_pickle = pickle.dumps(creds)
+ creds_base64 = base64.b64encode(creds_pickle)
+ token_file.write(creds_base64)
+ print("Token now saved in {}".format(TOKEN_FILE))
+ else:
+ print("Valid token in {} left unchanged.".format(TOKEN_FILE))