| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
|
| 5 |
import httpx |
| 6 |
|
| 7 |
SDK_DEFAULT_TIMEOUT = 60 |
| 8 |
|
| 9 |
try: |
| 10 |
import httpx_aiohttp |
| 11 |
except ImportError: |
| 12 |
|
| 13 |
class DefaultAioHttpClient(httpx.AsyncClient): |
| 14 |
def __init__(self, **kwargs: typing.Any) -> None: |
| 15 |
raise RuntimeError( |
| 16 |
"To use the aiohttp client, install the aiohttp extra: pip install auth0-python[aiohttp]" |
| 17 |
) |
| 18 |
|
| 19 |
else: |
| 20 |
|
| 21 |
class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): |
| 22 |
def __init__(self, **kwargs: typing.Any) -> None: |
| 23 |
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT) |
| 24 |
kwargs.setdefault("follow_redirects", True) |
| 25 |
super().__init__(**kwargs) |
| 26 |
|
| 27 |
|
| 28 |
class DefaultAsyncHttpxClient(httpx.AsyncClient): |
| 29 |
def __init__(self, **kwargs: typing.Any) -> None: |
| 30 |
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT) |
| 31 |
kwargs.setdefault("follow_redirects", True) |
| 32 |
super().__init__(**kwargs) |