Skip to content

Commit

Permalink
Simplify store_oauth2_credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbez committed Aug 19, 2016
1 parent 61a3f63 commit 73654f4
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/gmv/credential_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,15 @@ def store_oauth2_credentials(cls, email, access_token, refresh_token, validity,
"""
oauth_file = '%s/%s.oauth2' % (gmvault_utils.get_home_dir_path(), email)

# Open a file
fdesc = os.open(oauth_file, os.O_RDWR|os.O_CREAT )

#write new content
fobj = os.fdopen(fdesc, "w")

#empty file
fobj.truncate()
fobj.seek(0, os.SEEK_SET)


the_obj = { "access_token" : access_token,
"refresh_token" : refresh_token,
"validity" : validity,
"access_creation" : gmvault_utils.get_utcnow_epoch(),
"type" : type}

json.dump(the_obj, fobj)
with open(oauth_file, 'w') as f:
json.dump(the_obj, f)

fobj.close()

@classmethod
def read_oauth2_tok_sec(cls, email):
Expand Down

0 comments on commit 73654f4

Please sign in to comment.