Updated patched VK and core methods

This commit is contained in:
Manuel Cortez 2018-12-24 08:54:53 -06:00
parent 081f51dfd2
commit c442aac0a9
2 changed files with 15 additions and 4 deletions

View File

@ -1,8 +1,9 @@
import _sslfixer import _sslfixer
import webbrowser
import random import random
import requests import requests
import string import string
from wxUI import two_factor_auth
class AuthenticationError(Exception): class AuthenticationError(Exception):
pass pass
@ -24,7 +25,7 @@ api_url = 'https://api.vk.com/method/'
def requestAuth(login, password, scope=scope): def requestAuth(login, password, scope=scope):
if not (login or password): if not (login or password):
raise ValueError 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 = { headers = {
'User-Agent': user_agent 'User-Agent': user_agent
} }
@ -35,6 +36,16 @@ def requestAuth(login, password, scope=scope):
user_id = str(res['user_id']) user_id = str(res['user_id'])
return access_token, user_id return access_token, user_id
else: 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) raise AuthenticationError(r.text)
def getReceipt(user_id): def getReceipt(user_id):

View File

@ -16,8 +16,8 @@ class VkApi(vk_api.VkApi):
def __init__(self, login=None, password=None, token=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.92', app_id=6222115, scope=DEFAULT_USER_SCOPE, api_version='5.92', app_id=2685278, scope=DEFAULT_USER_SCOPE,
client_secret=None): client_secret='lxhD8OD7dMsqtXIm5IUY'):
self.login = login self.login = login
self.password = password self.password = password