auth_with_example.get_auth_cookies_with_example()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0
cc 2
nop 0
1
import asyncio
2
from univk_audio import AsyncVKAuth
3
4
# Example with 'async with' construction, that closes session automatically
5
6
async def get_auth_cookies_with_example():
7
    login: str = "79998887776"
8
    password: str = "password"
9
10
    # user_agent is optional:
11
    user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
12
13
    async with AsyncVKAuth(login = login, password = password, user_agent = user_agent) as auth:
14
15
        # .get_auth_cookies Returns a string with cookies
16
        # path is optional, if specified - saves cookies in file
17
18
        cookies = await auth.get_auth_cookies(path = "cookies.txt")
19
20
        print(cookies)
21
22
asyncio.run(get_auth_cookies_with_example())
23