Commit e3db177d authored by Manuel Cortez's avatar Manuel Cortez

Updated socializer to support again two factor verification

parent f43e9ffc
Pipeline #923 failed with stage
in 6 minutes and 20 seconds
......@@ -6,6 +6,10 @@
* the spelling correction module is able to add words to the dictionary so it will learn which words should start to ignore.
### bugfixes
* Now it is possible to perform authentication in accounts using two factor verification again. This issue was caused due to a recent change in the VK workflow for two factor verification processes.
### Changes
* The spelling correction module has been rewritten to take advantage of the newest enchant Python module which is more stable and can be added properly to the distribution, as opposed to the first enchant module we have tried.
......
#! /usr/bin/env python
""" Upload socializer to the ftp server. This script has been created to be executed from a continuous integrations system.
Important note: for this script to work, the following conditions should be met:
* There must be ftp server data, via environment variables (FTP_SERVER, FTP_USERNAME and FTP_PASSWORD) or via arguments to the script call (in the prior order). Connection to this server is done via default ftp port.
* There must be ftp server data, via environment variables (FTP_SERVER, FTP_USERNAME and FTP_PASSWORD) or via arguments to the script call (in the prior order). Connection to this server is done via default ftp port via TLS.
* this code assumes it's going to connect to an FTP via TLS.
* If the version to upload is alpha, there's not need of an extra variable. Otherwise, CI_COMMIT_TAG should point to a version as vx.x, where v is a literal and x are numbers, example may be v0.18, v0.25, v0.3. This variable should be set in the environment.
* Inside the ftp server, the following directory structure will be expected: socializer.su/static/files/. The script will create the <version> folder or alpha if needed.
* The script will upload all .exe, .zip and .json files located in the root directory from where it was called. The json files are uploaded to socializer.su/static/files/update and other files are going to socializer.su/static/files/<version>.
......@@ -40,7 +41,7 @@ version = os.environ.get("CI_COMMIT_TAG") or "alpha"
version = version.replace("v", "")
print("Uploading files to the Socializer server...")
connection = ftplib.FTP(ftp_server)
connection = ftplib.FTP_TLS(ftp_server)
print("Connected to FTP server {}".format(ftp_server,))
connection.login(user=ftp_username, passwd=ftp_password)
print("Logged in successfully")
......
# -*- coding: utf-8 -*-
""" Set of methods used to retrieve access tokens by simulating the official VK application for Android. """
""" Set of methods used to retrieve access tokens by simulating the official VK application for Android.
This is a Python port of the PHP module developed by Vodka2 to retrieve VK audio tokens. More info at https://github.com/vodka2/vk-audio-token
This module, as a Python port, just tries to get the tokens by using the Official VK app's tokens. I did not implemented the Kate mobile functionality as it involves a lot of more work and is not giving any advantage over the official way.
there are a lot of features pending to be applied. Hopefully later I can make it working more efficiently and OOP based.
"""
import random
import requests
import logging
......@@ -60,12 +64,19 @@ def get_non_refreshed(login, password, scope=scope):
params["2fa_supported"] = 1
headers = {'User-Agent': user_agent}
r = requests.get(url, params=params, headers=headers)
# Let's print this into logs as exceptions so we can catch future errors.
log.exception(r.json())
# If a 401 error is raised, we need to use 2FA here.
# see https://vk.com/dev/auth_direct (switch lang to russian, english docs are very incomplete in the matter)
# ToDo: this needs testing after implemented official VK tokens.
if r.status_code == 401 and "phone_mask" in r.text:
t = r.json()
log.exception(t)
validation_sid = t["validation_sid"]
url = "https://api.vk.com/method/auth.validatePhone"
params = dict(v="5.95", sid=validation_sid)
validated = requests.get(url, params=params, headers=headers)
log.exception(validated.json())
code, remember = two_factor_auth()
url = "https://oauth.vk.com/token"
params = dict(grant_type="password", lang="en",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment