Skip to content

Commit

Permalink
add async_token function
Browse files Browse the repository at this point in the history
  • Loading branch information
theGowda committed Nov 26, 2024
1 parent 01639e9 commit eca271a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions librouteros/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ def plain(api: typing.Any, username: str, password: str) -> None:

async def async_plain(api, username, password):
[response async for response in api("/login", **{"name": username, "password": password})]


async def async_token(api: typing.Any, username: str, password: str) -> None:
"""Login using pre routeros 6.43 authorization method."""
sentence = [response async for response in api("/login")]
tok = sentence[0]["ret"]
encoded = encode_password(tok, password)
[response async for response in api("/login", **{"name": username, "response": encoded})]

0 comments on commit eca271a

Please sign in to comment.