From c442aac0a98bf833e2d4ee083eed4a300cfbfc24 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Mon, 24 Dec 2018 08:54:53 -0600 Subject: [PATCH] Updated patched VK and core methods --- src/sessionmanager/core.py | 15 +++++++++++++-- src/sessionmanager/vk_api_patched.py | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/sessionmanager/core.py b/src/sessionmanager/core.py index 6927aea..c29e652 100644 --- a/src/sessionmanager/core.py +++ b/src/sessionmanager/core.py @@ -1,8 +1,9 @@ import _sslfixer +import webbrowser import random import requests import string - +from wxUI import two_factor_auth class AuthenticationError(Exception): pass @@ -24,7 +25,7 @@ api_url = 'https://api.vk.com/method/' def requestAuth(login, password, scope=scope): if not (login or password): raise ValueError - url = 'https://oauth.vk.com/token?grant_type=password&client_id='+client_id+'&client_secret='+client_secret+'&username='+login+'&password='+password+'&v='+api_ver+'&scope='+scope + url = 'https://oauth.vk.com/token?grant_type=password&2fa_supported=1&client_id='+client_id+'&client_secret='+client_secret+'&username='+login+'&password='+password+'&v='+api_ver+'&scope='+scope headers = { 'User-Agent': user_agent } @@ -35,6 +36,16 @@ def requestAuth(login, password, scope=scope): user_id = str(res['user_id']) return access_token, user_id else: + # Two factor auth is not supported in this method as it returns invalid code all the time. +# t = r.json() +# print t +# q = requests.get(t["redirect_uri"], headers=headers) +# print q.text +# code, remember = two_factor_auth() +# url = 'https://oauth.vk.com/token?grant_type=password&client_id='+client_id+'&client_secret='+client_secret+'&username='+login+'&password='+password+'&v='+api_ver+'&scope='+scope+'&code='+code+'&remember_device='+str(int(remember)) +# print url +# r = requests.get(url, headers=headers) +# print r.text raise AuthenticationError(r.text) def getReceipt(user_id): diff --git a/src/sessionmanager/vk_api_patched.py b/src/sessionmanager/vk_api_patched.py index b6ae4a0..4c6b7fa 100644 --- a/src/sessionmanager/vk_api_patched.py +++ b/src/sessionmanager/vk_api_patched.py @@ -16,8 +16,8 @@ class VkApi(vk_api.VkApi): 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.92', app_id=6222115, scope=DEFAULT_USER_SCOPE, - client_secret=None): + api_version='5.92', app_id=2685278, scope=DEFAULT_USER_SCOPE, + client_secret='lxhD8OD7dMsqtXIm5IUY'): self.login = login self.password = password