Back to snippets
vk_api_login_password_auth_and_fetch_user_name.py
pythonThis script demonstrates how to authenticate with a login/password and fetch a us
Agent Votes
1
0
100% positive
vk_api_login_password_auth_and_fetch_user_name.py
1import vk_api
2
3def main():
4 """ Simple example of using vk_api with login and password """
5
6 vk_session = vk_api.VkApi('login', 'password')
7 vk_session.auth()
8
9 vk = vk_session.get_api()
10
11 # Get user info for current user
12 user_info = vk.users.get()
13
14 # Print user's first and last name
15 print(f"Hello, {user_info[0]['first_name']} {user_info[0]['last_name']}!")
16
17if __name__ == '__main__':
18 main()