Skip to content

Commit bc55003

Browse files
authored
Merge pull request #695 from MeggyCal/master
Support httpx 0.28
2 parents 27fb1fd + 1d10ff3 commit bc55003

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

authlib/integrations/httpx_client/assertion_client.py

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def __init__(self, token_endpoint, issuer, subject, audience=None, grant_type=No
2222
claims=None, token_placement='header', scope=None, **kwargs):
2323

2424
client_kwargs = extract_client_kwargs(kwargs)
25+
# app keyword was dropped!
26+
app_value = client_kwargs.pop('app', None)
27+
if app_value is not None:
28+
client_kwargs['transport'] = httpx.ASGITransport(app=app_value)
29+
2530
httpx.AsyncClient.__init__(self, **client_kwargs)
2631

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

6368
client_kwargs = extract_client_kwargs(kwargs)
69+
# app keyword was dropped!
70+
app_value = client_kwargs.pop('app', None)
71+
if app_value is not None:
72+
client_kwargs['transport'] = httpx.WSGITransport(app=app_value)
73+
6474
httpx.Client.__init__(self, **client_kwargs)
6575

6676
_AssertionClient.__init__(

authlib/integrations/httpx_client/oauth1_client.py

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def __init__(self, client_id, client_secret=None,
3434
force_include_body=False, **kwargs):
3535

3636
_client_kwargs = extract_client_kwargs(kwargs)
37+
# app keyword was dropped!
38+
app_value = _client_kwargs.pop('app', None)
39+
if app_value is not None:
40+
_client_kwargs['transport'] = httpx.ASGITransport(app=app_value)
41+
3742
httpx.AsyncClient.__init__(self, **_client_kwargs)
3843

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

8994
_client_kwargs = extract_client_kwargs(kwargs)
95+
# app keyword was dropped!
96+
app_value = _client_kwargs.pop('app', None)
97+
if app_value is not None:
98+
_client_kwargs['transport'] = httpx.WSGITransport(app=app_value)
99+
90100
httpx.Client.__init__(self, **_client_kwargs)
91101

92102
_OAuth1Client.__init__(

authlib/integrations/httpx_client/oauth2_client.py

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def __init__(self, client_id=None, client_secret=None,
6262

6363
# extract httpx.Client kwargs
6464
client_kwargs = self._extract_session_request_params(kwargs)
65+
# app keyword was dropped!
66+
app_value = client_kwargs.pop('app', None)
67+
if app_value is not None:
68+
client_kwargs['transport'] = httpx.ASGITransport(app=app_value)
69+
6570
httpx.AsyncClient.__init__(self, **client_kwargs)
6671

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

178183
# extract httpx.Client kwargs
179184
client_kwargs = self._extract_session_request_params(kwargs)
185+
# app keyword was dropped!
186+
app_value = client_kwargs.pop('app', None)
187+
if app_value is not None:
188+
client_kwargs['transport'] = httpx.WSGITransport(app=app_value)
189+
180190
httpx.Client.__init__(self, **client_kwargs)
181191

182192
_OAuth2Client.__init__(

tests/clients/test_httpx/test_async_oauth2_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from unittest import mock
55
from copy import deepcopy
66

7-
from httpx import AsyncClient
7+
from httpx import AsyncClient, ASGITransport
88

99
from authlib.common.security import generate_token
1010
from authlib.common.urls import url_encode
@@ -96,7 +96,7 @@ async def test_add_token_to_streaming_request(assert_func, token_placement):
9696
token_placement="header",
9797
app=AsyncMockDispatch({'a': 'a'}, assert_func=assert_token_in_header)
9898
),
99-
AsyncClient(app=AsyncMockDispatch({'a': 'a'}))
99+
AsyncClient(transport=ASGITransport(app=AsyncMockDispatch({'a': 'a'})))
100100
])
101101
async def test_httpx_client_stream_match(client):
102102
async with client as client_entered:

0 commit comments

Comments
 (0)