· 5 years ago · Oct 05, 2020, 09:46 AM
1import aiohttp
2import uuid
3
4user_agent = u'VKAndroidApp/5.52-4543 (Android 5.1.1; SDK 22; x86_64; unknown Android SDK built for x86_64; en; 320x240)'
5client_id = u'2274003'
6secret_key = u'hHbZxrka2uZ6jB1inYsH'
7
8
9headers = {"User-Agent": user_agent}
10
11
12async def get_token(username, password):
13
14 async with aiohttp.ClientSession(headers=headers) as session:
15 device_id = uuid.uuid4().hex[:16]
16 params = {
17 "grant_type": "password",
18 "client_id": client_id,
19 "client_secret": secret_key,
20 'username': username,
21 'password': password,
22 'v': '5.116',
23 'lang': 'en',
24 'scope': "all",
25 'device_id': device_id,
26 }
27
28 response = await session.get("https://oauth.vk.com/token", params=params)
29 print(await response.json())