Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
aiohttp-oauth2-session
Advanced tools
A fully typed, package that adds OAuth2 support for aiohttp.ClientSession.
A fully typed package that adds OAuth2 support for aiohttp.ClientSession.
pip install aiohttp-oauth2-session
from aiohttp_oauth2_session import OAuth2Session
You can create a session with or without a token already known.
token = {
"access_token": "abc1234",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "def5678",
}
session = OAuth2Session(
client_id="client_id",
client_secret="client_secret",
redirect_uri="https://example.com/oauth/redirect",
scope="scope1 scope2",
token=token,
)
# Which allows you to make authenticated requests straight away.
resp = await session.get("https://example.com/api/resource")
await session.close()
You can also create a session without a token and fetch one later.
session = OAuth2Session(
client_id="client_id",
client_secret="client_secret",
redirect_uri="https://example.com/oauth/redirect",
scope="scope1 scope2",
)
await session.fetch_token(
token_url="https://example.com/oauth/token",
authorization_response="https://example.com/oauth/redirect?code=abc1234",
)
# now you can make authenticated requests.
resp = await session.get("https://example.com/api/resource")
await session.close()
You can also use context managers to automatically close the session.
async with OAuth2Session(
client_id="client_id",
client_secret="client_secret",
redirect_uri="https://example.com/oauth/redirect",
scope="scope1 scope2",
) as session:
await session.fetch_token(
token_url="https://example.com/oauth/token",
authorization_response="https://example.com/oauth/redirect?code=abc1234",
)
async with session.get("https://example.com/api/resource") as resp:
print(await resp.json())
What still needs to be done:
This package is based on a gist by kellerza. Thank you very much!
FAQs
A fully typed, package that adds OAuth2 support for aiohttp.ClientSession.
We found that aiohttp-oauth2-session demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.