Rebert back to use token as normally

This commit is contained in:
Manuel Cortez 2021-04-22 11:20:36 -05:00
parent a59e7a9c53
commit f8e8a11f96
3 changed files with 6 additions and 20 deletions

View File

@ -135,13 +135,8 @@ class vkSession(object):
return
try:
config_filename = os.path.join(paths.config_path(), self.session_id, "vkconfig.json")
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"], token=self.settings["vk"]["token"], secret=self.settings["vk"]["secret"], device_id=self.settings["vk"]["device_id"], alt_token=self.settings["vk"]["use_alternative_tokens"], filename=config_filename)
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"], token=self.settings["vk"]["token"], alt_token=self.settings["vk"]["use_alternative_tokens"], filename=config_filename)
self.settings["vk"]["token"] = self.vk.session_object.token["access_token"]
try:
self.settings["vk"]["secret"] = self.vk.session_object.secret
self.settings["vk"]["device_id"] = self.vk.session_object.device_id
except AttributeError:
pass
self.settings.write()
self.logged = True
self.get_my_data()
@ -151,8 +146,6 @@ class vkSession(object):
self.settings["vk"]["user"] = ""
self.settings["vk"]["password"] = ""
self.settings["vk"]["token"] = ""
self.settings["vk"]["secret"] = ""
self.settings["vk"]["device_id"] = ""
self.settings.write()
pub.sendMessage("authorisation-failed")
else: # print out error so we we will handle it in future versions.

View File

@ -12,7 +12,7 @@ class vkObject(object):
def __init__(self):
self.api_key = keys.keyring.get_api_key()
def login(self, user, password, token, secret, device_id, alt_token, filename):
def login(self, user, password, token, alt_token, filename):
if alt_token == False:
log.info("Using kate's token...")
# Let's import the patched vk_api module for using a different user agent
@ -20,11 +20,9 @@ class vkObject(object):
if token == "" or token == None:
log.info("Token is not valid. Generating one...")
original_token = official.login(user, password)
token = original_token[0]
secret = original_token[1]
device_id = original_token[2]
token = original_token
log.info("Token validated...")
self.session_object = vk_api.VkApi(app_id=self.api_key, login=user, password=password, token=token, secret=secret, device_id=device_id, scope="offline, wall, notify, friends, photos, audio, video, docs, notes, pages, status, groups, messages, notifications, stats", config_filename=filename)
self.session_object = vk_api.VkApi(app_id=self.api_key, login=user, password=password, token=token, scope="all", config_filename=filename)
else:
import vk_api
self.session_object = vk_api.VkApi(app_id=self.api_key, login=user, password=password, scope="offline, wall, notify, friends, photos, audio, video, docs, notes, pages, status, groups, messages, notifications, stats", config_filename=filename, auth_handler=two_factor_auth)

View File

@ -7,7 +7,6 @@ import logging
import vk_api
import threading
import requests
from authenticator.official import get_sig
from . import jconfig_patched as jconfig
from vk_api.enums import VkUserPermissions
from vk_api.exceptions import *
@ -16,7 +15,7 @@ DEFAULT_USER_SCOPE = sum(VkUserPermissions)
class VkApi(vk_api.VkApi):
def __init__(self, login=None, password=None, token=None, secret=None, device_id=None,
def __init__(self, login=None, password=None, token=None,
auth_handler=None, captcha_handler=None,
config=jconfig.Config, config_filename='vk_config.v2.json',
api_version='5.101', app_id=2685278, scope=DEFAULT_USER_SCOPE,
@ -26,8 +25,6 @@ class VkApi(vk_api.VkApi):
self.password = password
self.token = {'access_token': token}
self.secret = secret
self.device_id = device_id
self.api_version = api_version
self.app_id = app_id
self.scope = scope
@ -93,9 +90,7 @@ class VkApi(vk_api.VkApi):
if delay > 0:
time.sleep(delay)
values.update(https=1, device_id=self.device_id)
sig = get_sig(method, values, self.secret)
values.update(sig=sig)
values.update(https=1)
response = self.http.post(
'https://api.vk.com/method/' + method,
values