Answer the question
In order to leave comments, you need to log in
How to log in to VK using the vk api library?
I tried everything I could find on the internet.
import vk
app_id, login, password = '6126300', 'login', 'password'
session = vk.AuthSession(app_id, login, password, scope='messages')
vk_api = vk.API(session, v='5.67')
vk_api.wall.post(message="hello world")
session = vk.Session(access_token='793ac3c7c978d96f8ea1357747393bad78836ac813e7217baa5b37b3111c16b13514d41026f183fc0b359')
api = vk.API(session)
api.wall.post(message="Hello, world")
Answer the question
In order to leave comments, you need to log in
Authorization is successful.
The error is that you are trying to write on the wall without certain permissions . In order to do this, you need to set permissions, wall
or instead use a method that you have permissions to (based on the text of the question):api.wall.post(message="Hello, world")
api.messages.send(user_id=*любой_юзер*, message=*любое_сообщение*)
There is an error in the library
You can write in PM , I can throw off a similar library, which
1) Authentication is 2 times faster
2) It takes much less space
And authentication by a login-password pair works (there is no need to parse pages, as vk does)
A in general, you can make a request like " https://oauth.vk.com/token?grant_type=password&pas... <password>&username=<login>&client_secret=<application secret>〈=ru&libverify_support=1&client_id=&2fa_supported=1&scope=all "
It will return {"access_token": '', "expire_in": "<how long the token will expire>"}
token = vk_api.VkApi(token = "")
vk = token.get_api()
vk.messages.send(user_id = "твой id", message = "Твой текст", random_id = 0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question