Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support httpx 0.28 #695

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions authlib/integrations/httpx_client/assertion_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def __init__(self, token_endpoint, issuer, subject, audience=None, grant_type=No
claims=None, token_placement='header', scope=None, **kwargs):

client_kwargs = extract_client_kwargs(kwargs)
# app keyword was dropped!
app_value = client_kwargs.pop('app', None)
if app_value is not None:
client_kwargs['transport'] = httpx.ASGITransport(app=app_value)

httpx.AsyncClient.__init__(self, **client_kwargs)

_AssertionClient.__init__(
Expand Down Expand Up @@ -61,6 +66,11 @@ def __init__(self, token_endpoint, issuer, subject, audience=None, grant_type=No
claims=None, token_placement='header', scope=None, **kwargs):

client_kwargs = extract_client_kwargs(kwargs)
# app keyword was dropped!
app_value = client_kwargs.pop('app', None)
if app_value is not None:
client_kwargs['transport'] = httpx.WSGITransport(app=app_value)

httpx.Client.__init__(self, **client_kwargs)

_AssertionClient.__init__(
Expand Down
10 changes: 10 additions & 0 deletions authlib/integrations/httpx_client/oauth1_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def __init__(self, client_id, client_secret=None,
force_include_body=False, **kwargs):

_client_kwargs = extract_client_kwargs(kwargs)
# app keyword was dropped!
app_value = _client_kwargs.pop('app', None)
if app_value is not None:
_client_kwargs['transport'] = httpx.ASGITransport(app=app_value)

httpx.AsyncClient.__init__(self, **_client_kwargs)

_OAuth1Client.__init__(
Expand Down Expand Up @@ -87,6 +92,11 @@ def __init__(self, client_id, client_secret=None,
force_include_body=False, **kwargs):

_client_kwargs = extract_client_kwargs(kwargs)
# app keyword was dropped!
app_value = _client_kwargs.pop('app', None)
if app_value is not None:
_client_kwargs['transport'] = httpx.WSGITransport(app=app_value)

httpx.Client.__init__(self, **_client_kwargs)

_OAuth1Client.__init__(
Expand Down
10 changes: 10 additions & 0 deletions authlib/integrations/httpx_client/oauth2_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def __init__(self, client_id=None, client_secret=None,

# extract httpx.Client kwargs
client_kwargs = self._extract_session_request_params(kwargs)
# app keyword was dropped!
app_value = client_kwargs.pop('app', None)
if app_value is not None:
client_kwargs['transport'] = httpx.ASGITransport(app=app_value)

httpx.AsyncClient.__init__(self, **client_kwargs)

# We use a Lock to synchronize coroutines to prevent
Expand Down Expand Up @@ -177,6 +182,11 @@ def __init__(self, client_id=None, client_secret=None,

# extract httpx.Client kwargs
client_kwargs = self._extract_session_request_params(kwargs)
# app keyword was dropped!
app_value = client_kwargs.pop('app', None)
if app_value is not None:
client_kwargs['transport'] = httpx.WSGITransport(app=app_value)

httpx.Client.__init__(self, **client_kwargs)

_OAuth2Client.__init__(
Expand Down
4 changes: 2 additions & 2 deletions tests/clients/test_httpx/test_async_oauth2_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from unittest import mock
from copy import deepcopy

from httpx import AsyncClient
from httpx import AsyncClient, ASGITransport

from authlib.common.security import generate_token
from authlib.common.urls import url_encode
Expand Down Expand Up @@ -96,7 +96,7 @@ async def test_add_token_to_streaming_request(assert_func, token_placement):
token_placement="header",
app=AsyncMockDispatch({'a': 'a'}, assert_func=assert_token_in_header)
),
AsyncClient(app=AsyncMockDispatch({'a': 'a'}))
AsyncClient(transport=ASGITransport(app=AsyncMockDispatch({'a': 'a'})))
])
async def test_httpx_client_stream_match(client):
async with client as client_entered:
Expand Down
Loading