Skip to content
Open
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
1 change: 0 additions & 1 deletion stubs/Authlib/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,5 @@ authlib.integrations.django_oauth2.*
authlib.integrations.flask_client.*
authlib.integrations.flask_oauth1.*
authlib.integrations.flask_oauth2.*
authlib.integrations.httpx_client.*
authlib.integrations.sqla_oauth2.*
authlib.integrations.starlette_client.*
4 changes: 2 additions & 2 deletions stubs/Authlib/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.7.2"
version = "1.8.0"
upstream-repository = "https://github.com/authlib/authlib"
dependencies = ["cryptography"]
optional-dependencies = ["requests"]
optional-dependencies = ["requests", "httpx2"]
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from _typeshed import Incomplete

import httpx2
from authlib.oauth2.rfc7521 import AssertionClient as _AssertionClient

from ..base_client import OAuthError
from .oauth2_client import OAuth2Auth

USE_CLIENT_DEFAULT = httpx2.USE_CLIENT_DEFAULT
Response = httpx2.Response

__all__ = ["AsyncAssertionClient"]

# Inherits from httpx.AsyncClient
class AsyncAssertionClient(_AssertionClient):
class AsyncAssertionClient(_AssertionClient, httpx2.AsyncClient):
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
JWT_BEARER_GRANT_TYPE: Incomplete
Expand All @@ -24,12 +27,12 @@ class AsyncAssertionClient(_AssertionClient):
claims=None,
token_placement="header",
scope=None,
client_id=None,
**kwargs,
) -> None: ...
async def request(self, method, url, withhold_token=False, auth=..., **kwargs): ...

# Inherits from httpx.Client
class AssertionClient(_AssertionClient):
class AssertionClient(_AssertionClient, httpx2.Client):
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
JWT_BEARER_GRANT_TYPE: Incomplete
Expand All @@ -45,6 +48,7 @@ class AssertionClient(_AssertionClient):
claims=None,
token_placement="header",
scope=None,
client_id=None,
**kwargs,
) -> None: ...
def request(self, method, url, withhold_token=False, auth=..., **kwargs): ...
19 changes: 8 additions & 11 deletions stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import TypeAlias
from typing_extensions import Never

import httpx2
from authlib.oauth1 import ClientAuth
from authlib.oauth1.client import OAuth1Client as _OAuth1Client

_Response: TypeAlias = Incomplete # actual type is httpx.Response
_Request: TypeAlias = Incomplete # actual type is httpx.Request
Auth = httpx2.Auth
Request = httpx2.Request
Response = httpx2.Response

# Inherits from httpx.Auth
class OAuth1Auth(ClientAuth):
class OAuth1Auth(Auth, ClientAuth):
requires_request_body: bool
def auth_flow(self, request: _Request) -> Generator[_Request, _Response]: ...
def auth_flow(self, request: Request) -> Generator[Request, Response]: ...

# Inherits from httpx.AsyncClient
class AsyncOAuth1Client(_OAuth1Client):
class AsyncOAuth1Client(_OAuth1Client, httpx2.AsyncClient): # type: ignore[misc] # incompatible definitions of "auth" in the base classes
auth_class = OAuth1Auth
def __init__(
self,
Expand All @@ -35,8 +33,7 @@ class AsyncOAuth1Client(_OAuth1Client):
@staticmethod
def handle_error(error_type: str | None, error_description: str | None) -> Never: ...

# Inherits from httpx.Client
class OAuth1Client(_OAuth1Client):
class OAuth1Client(_OAuth1Client, httpx2.Client): # type: ignore[misc] # incompatible definitions of "auth" in the base classes
auth_class = OAuth1Auth
def __init__(
self,
Expand Down
29 changes: 13 additions & 16 deletions stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import TypeAlias
from typing_extensions import Never

import httpx2
from authlib.oauth2.auth import ClientAuth, TokenAuth
from authlib.oauth2.client import OAuth2Client as _OAuth2Client

from ..base_client import OAuthError

__all__ = ["OAuth2Auth", "OAuth2ClientAuth", "AsyncOAuth2Client", "OAuth2Client"]
USE_CLIENT_DEFAULT = httpx2.USE_CLIENT_DEFAULT
Auth = httpx2.Auth
Request = httpx2.Request
Response = httpx2.Response

_Response: TypeAlias = Incomplete # actual type is httpx.Response
_Request: TypeAlias = Incomplete # actual type is httpx.Request
__all__ = ["OAuth2Auth", "OAuth2ClientAuth", "AsyncOAuth2Client", "OAuth2Client"]

# Inherits from httpx.Auth
class OAuth2Auth(TokenAuth):
class OAuth2Auth(Auth, TokenAuth):
requires_request_body: bool
def auth_flow(self, request: _Request) -> Generator[_Request, _Response]: ...
def auth_flow(self, request: Request) -> Generator[Request, Response]: ...

# Inherits from httpx.Auth
class OAuth2ClientAuth(ClientAuth):
class OAuth2ClientAuth(Auth, ClientAuth):
requires_request_body: bool
def auth_flow(self, request: _Request) -> Generator[_Request, _Response]: ...
def auth_flow(self, request: Request) -> Generator[Request, Response]: ...

# Inherits from httpx.AsyncClient
class AsyncOAuth2Client(_OAuth2Client):
class AsyncOAuth2Client(_OAuth2Client, httpx2.AsyncClient):
SESSION_REQUEST_PARAMS: list[str]
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
Expand All @@ -44,11 +42,10 @@ class AsyncOAuth2Client(_OAuth2Client):
**kwargs,
) -> None: ...
async def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Incomplete]: ...
async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Response]: ... # type: ignore[override]
async def ensure_active_token(self, token): ... # type: ignore[override]

# Inherits from httpx.Client
class OAuth2Client(_OAuth2Client):
class OAuth2Client(_OAuth2Client, httpx2.Client):
SESSION_REQUEST_PARAMS: list[str]
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
Expand Down
18 changes: 7 additions & 11 deletions stubs/Authlib/authlib/integrations/httpx_client/utils.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from _typeshed import Incomplete
from collections.abc import AsyncIterable, Iterable, Mapping, MutableMapping, Sequence
from typing import Final, TypeAlias
from typing import Final

import httpx2
from httpx2._types import HeaderTypes, RequestContent

HTTPX_CLIENT_KWARGS: Final[list[str]]

_Request: TypeAlias = Incomplete # actual type is httpx.Request
_URL: TypeAlias = Incomplete # actual type is httpx.URL
_Headers: TypeAlias = MutableMapping[str, str] # actual type is httpx.Headers
_HeaderTypes: TypeAlias = ( # actual type is httpx._types.HeaderTypes
_Headers | Mapping[str, str] | Mapping[bytes, bytes] | Sequence[tuple[str, str]] | Sequence[tuple[bytes, bytes]]
)
_RequestContent: TypeAlias = str | bytes | Iterable[bytes] | AsyncIterable[bytes] # actual type is httpx._types.RequestContent
Request = httpx2.Request

def extract_client_kwargs(kwargs: dict[str, Incomplete]) -> dict[str, Incomplete]: ...
def build_request(
url: _URL | str, headers: _HeaderTypes | None, body: _RequestContent, initial_request: _Request
) -> _Request: ...
url: httpx2.URL | str, headers: HeaderTypes | None, body: RequestContent, initial_request: httpx2.Request
) -> httpx2.Request: ...
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AssertionSession(AssertionClient):
claims=None,
token_placement="header",
scope=None,
client_id=None,
default_timeout=None,
leeway=60,
**kwargs,
Expand Down
2 changes: 2 additions & 0 deletions stubs/Authlib/authlib/oauth2/rfc7521/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AssertionClient:
audience: Incomplete
claims: Incomplete
scope: Incomplete
client_id: Incomplete
token_auth: Incomplete
leeway: Incomplete
def __init__(
Expand All @@ -28,6 +29,7 @@ class AssertionClient:
claims=None,
token_placement: str = "header",
scope=None,
client_id=None,
leeway: int = 60,
**kwargs,
) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class JWTBearerGrant(BaseGrant, TokenEndpointMixin):
def sign(key, issuer, audience, subject=None, issued_at=None, expires_at=None, claims=None, **kwargs): ...
def verify_claims(self, claims: dict[str, Incomplete]) -> None: ...
def process_assertion_claims(self, assertion) -> dict[str, Incomplete]: ...
def extract_assertion(self, assertion: str) -> tuple[dict[str, Incomplete], Incomplete]: ...
def extract_assertion(self, assertion: str) -> tuple[dict[str, Incomplete], dict[Incomplete, Incomplete]]: ...
def validate_token_request(self) -> None: ...
def create_token_response(self): ...
def resolve_issuer_client(self, issuer): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/Authlib/authlib/oauth2/rfc7523/token.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class JWTBearerTokenGenerator:
@staticmethod
def get_allowed_scope(client, scope): ...
@staticmethod
def get_sub_value(user): ...
def get_sub_value(user) -> str: ...
def get_token_data(self, grant_type, client, expires_in, user=None, scope=None): ...
def generate(self, grant_type, client, user=None, scope=None, expires_in=None): ...
def __call__(self, grant_type, client, user=None, scope=None, expires_in=None, include_refresh_token: bool = True): ...
3 changes: 2 additions & 1 deletion stubs/Authlib/authlib/oauth2/rfc7523/validator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ class JWTBearerTokenValidator(BearerTokenValidator):
token_cls = JWTBearerToken
public_key: Incomplete
claims_options: Incomplete
def __init__(self, public_key, issuer=None, realm=None, **extra_attributes) -> None: ...
leeway: int
def __init__(self, public_key, issuer=None, realm=None, leeway: int = 60, **extra_attributes) -> None: ...
def authenticate_token(self, token_string: str) -> JWTBearerToken | None: ...