Skip to content

Commit

Permalink
📝 update readme to mention async
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret committed Oct 23, 2024
1 parent f38745d commit 2b8575d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ Save the above as ``trophies.py`` and then execute via:
Additional examples can be found at:
https://github.com/praw-dev/prawcore/tree/main/examples

Or! with async/await!

.. code-block:: python
#!/usr/bin/env python
import os
import pprint
import asyncio
import prawcore
async def main():
authenticator = prawcore.AsyncTrustedAuthenticator(
prawcore.Requestor("YOUR_VALID_USER_AGENT"),
os.environ["PRAWCORE_CLIENT_ID"],
os.environ["PRAWCORE_CLIENT_SECRET"],
)
authorizer = prawcore.AsyncReadOnlyAuthorizer(authenticator)
await authorizer.refresh()
async with prawcore.async_session(authorizer) as session:
pprint.pprint(await session.request("GET", "/api/v1/user/bboe/trophies"))
asyncio.run(main())
Depending on prawcore
---------------------

Expand Down

0 comments on commit 2b8575d

Please sign in to comment.