Rebert back to use token as normally
This commit is contained in:
parent
a59e7a9c53
commit
f8e8a11f96
@ -135,13 +135,8 @@ class vkSession(object):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
config_filename = os.path.join(paths.config_path(), self.session_id, "vkconfig.json")
|
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"]
|
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.settings.write()
|
||||||
self.logged = True
|
self.logged = True
|
||||||
self.get_my_data()
|
self.get_my_data()
|
||||||
@ -151,8 +146,6 @@ class vkSession(object):
|
|||||||
self.settings["vk"]["user"] = ""
|
self.settings["vk"]["user"] = ""
|
||||||
self.settings["vk"]["password"] = ""
|
self.settings["vk"]["password"] = ""
|
||||||
self.settings["vk"]["token"] = ""
|
self.settings["vk"]["token"] = ""
|
||||||
self.settings["vk"]["secret"] = ""
|
|
||||||
self.settings["vk"]["device_id"] = ""
|
|
||||||
self.settings.write()
|
self.settings.write()
|
||||||
pub.sendMessage("authorisation-failed")
|
pub.sendMessage("authorisation-failed")
|
||||||
else: # print out error so we we will handle it in future versions.
|
else: # print out error so we we will handle it in future versions.
|
||||||
|
@ -12,7 +12,7 @@ class vkObject(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.api_key = keys.keyring.get_api_key()
|
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:
|
if alt_token == False:
|
||||||
log.info("Using kate's token...")
|
log.info("Using kate's token...")
|
||||||
# Let's import the patched vk_api module for using a different user agent
|
# 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:
|
if token == "" or token == None:
|
||||||
log.info("Token is not valid. Generating one...")
|
log.info("Token is not valid. Generating one...")
|
||||||
original_token = official.login(user, password)
|
original_token = official.login(user, password)
|
||||||
token = original_token[0]
|
token = original_token
|
||||||
secret = original_token[1]
|
|
||||||
device_id = original_token[2]
|
|
||||||
log.info("Token validated...")
|
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:
|
else:
|
||||||
import vk_api
|
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)
|
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)
|
||||||
|
@ -7,7 +7,6 @@ import logging
|
|||||||
import vk_api
|
import vk_api
|
||||||
import threading
|
import threading
|
||||||
import requests
|
import requests
|
||||||
from authenticator.official import get_sig
|
|
||||||
from . import jconfig_patched as jconfig
|
from . import jconfig_patched as jconfig
|
||||||
from vk_api.enums import VkUserPermissions
|
from vk_api.enums import VkUserPermissions
|
||||||
from vk_api.exceptions import *
|
from vk_api.exceptions import *
|
||||||
@ -16,7 +15,7 @@ DEFAULT_USER_SCOPE = sum(VkUserPermissions)
|
|||||||
|
|
||||||
class VkApi(vk_api.VkApi):
|
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,
|
auth_handler=None, captcha_handler=None,
|
||||||
config=jconfig.Config, config_filename='vk_config.v2.json',
|
config=jconfig.Config, config_filename='vk_config.v2.json',
|
||||||
api_version='5.101', app_id=2685278, scope=DEFAULT_USER_SCOPE,
|
api_version='5.101', app_id=2685278, scope=DEFAULT_USER_SCOPE,
|
||||||
@ -26,8 +25,6 @@ class VkApi(vk_api.VkApi):
|
|||||||
self.password = password
|
self.password = password
|
||||||
|
|
||||||
self.token = {'access_token': token}
|
self.token = {'access_token': token}
|
||||||
self.secret = secret
|
|
||||||
self.device_id = device_id
|
|
||||||
self.api_version = api_version
|
self.api_version = api_version
|
||||||
self.app_id = app_id
|
self.app_id = app_id
|
||||||
self.scope = scope
|
self.scope = scope
|
||||||
@ -93,9 +90,7 @@ class VkApi(vk_api.VkApi):
|
|||||||
|
|
||||||
if delay > 0:
|
if delay > 0:
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
values.update(https=1, device_id=self.device_id)
|
values.update(https=1)
|
||||||
sig = get_sig(method, values, self.secret)
|
|
||||||
values.update(sig=sig)
|
|
||||||
response = self.http.post(
|
response = self.http.post(
|
||||||
'https://api.vk.com/method/' + method,
|
'https://api.vk.com/method/' + method,
|
||||||
values
|
values
|
||||||
|
Loading…
Reference in New Issue
Block a user