D
D
d3co92022-04-12 16:44:23
Python
d3co9, 2022-04-12 16:44:23

Authorization through vk-api does not work?

I'm trying to log in through the vk-api library, but it gives an error:

in _api_login
raise AuthError('API auth error (no login cookies)')
vk_api.exceptions.AuthError: API auth error (no login cookies)

Code below:

import vk_api

vk_session = vk_api.VkApi('+7999999999, '*****')
vk_session.auth()

vk = vk_session.get_api()

print(vk.wall.post(message='Hello world!'))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2022-04-12
@HemulGM

No wonder, this is not an official authorization option. Officially, you can not log in with a number and password.
I do not recommend you to use such authorization. It is not safe, not stable and there is no guarantee that it will work even after a week.

N
nnikolyaa, 2022-04-14
@nnikolyaa

Why invent a crutch? And there is no such method of official authorization. Maybe there is through capturing cookies with requests, but this is difficult. It's easier to do it with a user token.

  1. Go to the site and in "Settings >>" put the necessary checkboxes.
  2. After that, a site will open with a request for access or authorization (if you are not logged into your account).
  3. Allow access.
  4. The link will contain your token, copy it and paste it into the code

import vk_api

vkApiSession= vk_api.VkApi(token="ключ апи")

vkU = vkApiSession.get_api()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question