Fixed error when getting VK API error 5. Closes #11

This commit is contained in:
Manuel Cortez 2018-09-03 09:15:52 -05:00
parent 72348008a2
commit e77276ae52

View File

@ -9,6 +9,7 @@ import utils
import sound import sound
from config_utils import Configuration, ConfigurationResetException from config_utils import Configuration, ConfigurationResetException
from pubsub import pub from pubsub import pub
from vk.exceptions import VkAPIError
log = logging.getLogger("session") log = logging.getLogger("session")
@ -218,11 +219,15 @@ class vkSession(object):
If the access_token has expired, it will call authorise() too, for getting a new access token.""" If the access_token has expired, it will call authorise() too, for getting a new access token."""
if self.settings["vk"]["token"] != None: if self.settings["vk"]["token"] != None:
try:
result = self.vk.login_access_token(self.settings["vk"]["token"]) result = self.vk.login_access_token(self.settings["vk"]["token"])
self.logged = True self.logged = True
log.debug("Logged.") log.debug("Logged.")
if result == False: if result == False:
self.authorise() self.authorise()
except VkAPIError as err:
if err.code == 5:
self.authorise()
else: else:
self.authorise() self.authorise()
self.get_my_data() self.get_my_data()