Пример #1
0
    def checkData(self):
        """
		Checks the token or authorizes by password
		Raises api.TokenError if token is invalid or missed in hell
		Raises api.VkApiError if phone/password is invalid
		"""
        logger.debug("VK: checking data")

        if self.engine.token:
            logger.debug("VK.checkData: trying to use token")
            if not self.checkToken():
                logger.error("VK.checkData: token invalid: %s" %
                             self.engine.token)
                raise api.TokenError("Token is invalid: %s" %
                                     (self.engine.token))
        else:
            raise api.TokenError("%s, Where the hell is your token?" %
                                 self.source)
Пример #2
0
	def auth(self):
		"""
		Initializes the APIBinding object
		Returns:
			True if everything went fine
		"""
		logger.debug("VK going to authenticate (jid: %s)", self.source)
		self.engine = api.APIBinding(self.token, DEBUG_API, self.source)
		if not self.checkToken():
			raise api.TokenError("The token is invalid (jid: %s, token: %s)" % (self.source, self.token))
		self.online = True
		return True