diff --git a/stubs/Authlib/@tests/test_cases/check_oauth2_introspect.py b/stubs/Authlib/@tests/test_cases/check_oauth2_introspect.py new file mode 100644 index 000000000000..dd87286bf978 --- /dev/null +++ b/stubs/Authlib/@tests/test_cases/check_oauth2_introspect.py @@ -0,0 +1,13 @@ +from typing import Any +from typing_extensions import assert_type + +from authlib.integrations.httpx_client import AsyncOAuth2Client, OAuth2Client + + +async def check_async_introspect_token(client: AsyncOAuth2Client) -> None: + response = await client.introspect_token("https://example.com/introspect") + assert_type(response, Any) + + +def check_sync_introspect_token(client: OAuth2Client) -> None: + assert_type(client.introspect_token("https://example.com/introspect"), Any) diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi index 9493842b5378..f2c5a8eace4f 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from collections.abc import Generator -from typing import NoReturn, TypeAlias +from collections.abc import Awaitable, Generator +from typing import Any, NoReturn, TypeAlias from authlib.oauth2.auth import ClientAuth, TokenAuth from authlib.oauth2.client import OAuth2Client as _OAuth2Client @@ -45,6 +45,16 @@ class AsyncOAuth2Client(_OAuth2Client): 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 ensure_active_token(self, token): ... # type: ignore[override] + def introspect_token( + self, + url: str, + token: Any | None = None, + token_type_hint: str | None = None, + body: Any | None = None, + auth: Any = ..., + headers: Any | None = None, + **kwargs: Any, + ) -> Awaitable[_Response]: ... # Inherits from httpx.Client class OAuth2Client(_OAuth2Client): @@ -69,3 +79,13 @@ class OAuth2Client(_OAuth2Client): def handle_error(error_type: str | None, error_description: str | None) -> NoReturn: ... def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ... def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ... + def introspect_token( + self, + url: str, + token: Any | None = None, + token_type_hint: str | None = None, + body: Any | None = None, + auth: Any = ..., + headers: Any | None = None, + **kwargs: Any, + ) -> _Response: ... diff --git a/stubs/Authlib/authlib/oauth2/client.pyi b/stubs/Authlib/authlib/oauth2/client.pyi index c502a92b5e67..396af2cb9a7c 100644 --- a/stubs/Authlib/authlib/oauth2/client.pyi +++ b/stubs/Authlib/authlib/oauth2/client.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from typing import Any from authlib.oauth2 import ClientAuth, OAuth2Error, TokenAuth @@ -62,7 +63,16 @@ class OAuth2Client: def refresh_token(self, url=None, refresh_token=None, body: str = "", auth=None, headers=None, **kwargs): ... def ensure_active_token(self, token=None): ... def revoke_token(self, url, token=None, token_type_hint=None, body=None, auth=None, headers=None, **kwargs): ... - def introspect_token(self, url, token=None, token_type_hint=None, body=None, auth=None, headers=None, **kwargs): ... + def introspect_token( + self, + url: str, + token: Any | None = None, + token_type_hint: str | None = None, + body: Any | None = None, + auth: Any | None = None, + headers: Any | None = None, + **kwargs: Any, + ) -> Any: ... def register_compliance_hook(self, hook_type, hook) -> None: ... def parse_response_token(self, resp): ... def __del__(self) -> None: ...