remove token file if Dropbox authorization revoked

This commit is contained in:
Rob Weber 2012-12-13 14:18:14 -06:00
parent 018a1a1e82
commit 46cd3c6731
2 changed files with 14 additions and 1 deletions

View File

@ -2,6 +2,8 @@ Version 0.3.1
added try/except for multiple character encodings added try/except for multiple character encodings
remove token.txt file if Dropbox Authorization is revoked
Version 0.3.0 Version 0.3.0
major vfs rewrite major vfs rewrite

View File

@ -84,7 +84,13 @@ class DropboxFileSystem(Vfs):
sess.set_token(user_token_key,user_token_secret) sess.set_token(user_token_key,user_token_secret)
self.client = client.DropboxClient(sess) self.client = client.DropboxClient(sess)
try:
utils.log(str(self.client.account_info())) utils.log(str(self.client.account_info()))
except:
#this didn't work, delete the token file
self.deleteToken()
def listdir(self,directory): def listdir(self,directory):
if(self.client != None and self.exists(directory)): if(self.client != None and self.exists(directory)):
@ -150,6 +156,7 @@ class DropboxFileSystem(Vfs):
out.close() out.close()
else: else:
return False return False
def setToken(self,key,secret): def setToken(self,key,secret):
#write the token files #write the token files
token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w') token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w')
@ -167,6 +174,10 @@ class DropboxFileSystem(Vfs):
else: else:
return ["",""] return ["",""]
def deleteToken(self):
if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "tokens.txt"))):
xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "tokens.txt"))