Skip to content

Commit 1f20c36

Browse files
committed
Fix 2FA auth
1 parent 3709fbe commit 1f20c36

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

vk_api/vk_api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
RE_PHONE_PREFIX = re.compile(r'label ta_r">\+(.*?)<')
3838
RE_PHONE_POSTFIX = re.compile(r'phone_postfix">.*?(\d+).*?<')
3939

40-
DEFAULT_USERAGENT = 'Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0'
40+
DEFAULT_USERAGENT = 'Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0'
4141

4242
DEFAULT_USER_SCOPE = sum(VkUserPermissions)
4343

@@ -248,9 +248,11 @@ def _vk_login(self, captcha_sid=None, captcha_key=None):
248248
self.http.cookies.clear()
249249

250250
# Get cookies
251-
response = self.http.get('https://vk.com/')
251+
response = self.http.get('https://vk.com/login')
252252

253253
headers = {
254+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
255+
'Accept-Language': 'en-US,en;q=0.5',
254256
'Referer': 'https://vk.com/',
255257
'Content-Type': 'application/x-www-form-urlencoded',
256258
'Origin': 'https://vk.com',
@@ -358,7 +360,7 @@ def _pass_twofactor(self, auth_response):
358360

359361
if status == '4': # OK
360362
path = json.loads(data['payload'][1][0])
361-
return self.http.get('https://vk.com' + path)
363+
return self.http.get(path)
362364

363365
elif status in [0, '8']: # Incorrect code
364366
return self._pass_twofactor(auth_response)

0 commit comments

Comments
 (0)