-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 10e0c696388a5134724b0005cefbdeef | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Client | ||
====== | ||
|
||
.. automodule:: aiohttp_oauth2_client.client | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Grants | ||
============= | ||
|
||
|
||
The :obj:`~aiohttp_oauth2_client.grant.common.OAuth2Grant` abstract class defines the high-level interface for OAuth 2.0 grant implementations. | ||
The grant object should be used as an async context manager. | ||
|
||
Common | ||
------ | ||
.. automodule:: aiohttp_oauth2_client.grant.common | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Authorization Code | ||
------------------ | ||
|
||
.. automodule:: aiohttp_oauth2_client.grant.authorization_code | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Client Credentials | ||
------------------ | ||
|
||
.. automodule:: aiohttp_oauth2_client.grant.client_credentials | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Resource Owner Password Credentials | ||
----------------------------------- | ||
|
||
.. automodule:: aiohttp_oauth2_client.grant.resource_owner_password_credentials | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Device Code | ||
----------- | ||
|
||
.. automodule:: aiohttp_oauth2_client.grant.device_code | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Models | ||
====== | ||
|
||
The **models** package contains several data models and exceptions that are internally used throughout the code. | ||
End-users shouldn't have to deal with these classes, except for error handling. | ||
|
||
|
||
Errors | ||
------ | ||
|
||
All exceptions raised in the `aiohttp-oauth2-client` package inherit from the :obj:`aiohttp_oauth2_client.models.errors.AuthError` exception. | ||
This can be useful for catching auth errors in your code. | ||
|
||
.. automodule:: aiohttp_oauth2_client.models.errors | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Grant types | ||
----------- | ||
|
||
.. automodule:: aiohttp_oauth2_client.models.grant | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Proof Key for Code Exchange (PKCE) | ||
---------------------------------- | ||
|
||
.. automodule:: aiohttp_oauth2_client.models.pkce | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Request | ||
--------------------------------------------- | ||
|
||
.. automodule:: aiohttp_oauth2_client.models.request | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Response | ||
---------------------------------------------- | ||
|
||
.. automodule:: aiohttp_oauth2_client.models.response | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Token | ||
------------------------------------------- | ||
|
||
.. automodule:: aiohttp_oauth2_client.models.token | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
API | ||
=== | ||
|
||
.. automodule:: aiohttp_oauth2_client | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
|
||
.. toctree:: | ||
:maxdepth: 3 | ||
|
||
api.client | ||
api.grant | ||
api.models |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.. aiohttp-oauth2-client documentation master file, created by | ||
sphinx-quickstart on Tue May 21 16:32:43 2024. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
``aiohttp-oauth2-client``: OAuth2 support for ``aiohttp`` client | ||
================================================================ | ||
This package adds support for OAuth 2.0 authorization to the :obj:`~aiohttp.ClientSession` class of the ``aiohttp`` library. | ||
It handles retrieving access tokens and injects them in the *Authorization* header of HTTP requests as a Bearer token. | ||
|
||
**Features**: | ||
|
||
* Ease of use | ||
* Supported OAuth2 grants: | ||
|
||
* `Resource Owner Password Credentials <https://datatracker.ietf.org/doc/html/rfc6749#section-4.3>`_ | ||
* `Client Credentials <https://datatracker.ietf.org/doc/html/rfc6749#section-4.4>`_ | ||
* `Authorization Code (+ PKCE) <https://datatracker.ietf.org/doc/html/rfc6749#section-4.1>`_ | ||
* `Device Code (+ PKCE) <https://datatracker.ietf.org/doc/html/rfc8628>`_ | ||
* Automatic (lazy) refresh of tokens | ||
* Extensible code architecture | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
installation | ||
usage | ||
api | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Installation | ||
============ | ||
|
||
This package is available on `PyPi <https://pypi.org/project/aiohttp-oauth2-client/>`_ and can be installed using ``pip``:: | ||
|
||
pip install aiohttp-oauth2-client | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Usage | ||
===== | ||
|
||
Getting started | ||
--------------- | ||
|
||
Begin by importing the relevant modules, like the OAuth2 client and grant. Also import ``asyncio`` for running async code:: | ||
|
||
import asyncio | ||
from aiohttp_oauth2_client.client import OAuth2Client | ||
from aiohttp_oauth2_client.grant.device_code import DeviceCodeGrant | ||
|
||
|
||
Then create an :obj:`~aiohttp_oauth2_client.grant.common.OAuth2Grant` and :obj:`~aiohttp_oauth2_client.client.OAuth2Client` object and perform a HTTP request to a protected resource. We use the | ||
Device Code grant in this example:: | ||
|
||
async def main(): | ||
async with DeviceCodeGrant( | ||
token_url=TOKEN_URL, | ||
device_authorization_url=DEVICE_AUTHORIZATION_URL, | ||
client_id=CLIENT_ID, | ||
pkce=True | ||
) as grant, OAuth2Client(grant) as client: | ||
async with client.get(PROTECTED_ENDPOINT) as response: | ||
assert response.ok | ||
print(await response.text()) | ||
|
||
|
||
asyncio.run(main()) | ||
|
||
|
||
The client and grant objects can be used as async context managers. This ensures the proper setup and cleanup of | ||
associated resources. | ||
|
||
|
||
Grant configuration | ||
------------------- | ||
Each grant type has specific configuration options associated with it. | ||
Extra parameters can be provided, which will then be used in the authorization process. | ||
|
||
* :obj:`~aiohttp_oauth2_client.grant.authorization_code.AuthorizationCodeGrant` | ||
* :obj:`~aiohttp_oauth2_client.grant.client_credentials.ClientCredentialsGrant` | ||
* :obj:`~aiohttp_oauth2_client.grant.resource_owner_password_credentials.ResourceOwnerPasswordCredentialsGrant` | ||
* :obj:`~aiohttp_oauth2_client.grant.device_code.DeviceCodeGrant` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.autodoc_pydantic_validator_arrow { | ||
padding-left: 8px; | ||
} | ||
|
||
.autodoc_pydantic_collapsable_json { | ||
cursor: pointer; | ||
} | ||
|
||
.autodoc_pydantic_collapsable_erd { | ||
cursor: pointer; | ||
} |