Skip to content

Commit

Permalink
fix usage-guide/best-practices.md
Browse files Browse the repository at this point in the history
  • Loading branch information
subzeroid committed Mar 4, 2024
1 parent f1c123b commit 574d0a0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions docs/usage-guide/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,22 @@ The first time you run your script
``` python
from aiograpi import Client

cl = Client()
await cl.login(USERNAME, PASSWORD)
cl.dump_settings("session.json")
async def main():
cl = Client()
await cl.login(USERNAME, PASSWORD)
cl.dump_settings("session.json")
```

And the next time

``` python
from aiograpi import Client

cl = Client()
cl.load_settings("session.json")
await cl.login(USERNAME, PASSWORD) # this doesn't actually login using username/password but uses the session
await cl.get_timeline_feed() # check session
async def main():
cl = Client()
cl.load_settings("session.json")
await cl.login(USERNAME, PASSWORD) # this doesn't actually login using username/password but uses the session
await cl.get_timeline_feed() # check session
```

You'll notice we do a call to `await cl.get_timeline_feed()` to check if the session is valid. If it's not valid, you'll get an exception.
Expand All @@ -92,7 +94,7 @@ import logging

logger = logging.getLogger()

def login_user():
async def login_user():
"""
Attempts to login to Instagram using either the provided session information
or the provided username and password.
Expand Down

0 comments on commit 574d0a0

Please sign in to comment.