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
13 changes: 13 additions & 0 deletions stubs/Authlib/@tests/test_cases/check_oauth2_introspect.py
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 22 additions & 2 deletions stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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: ...
12 changes: 11 additions & 1 deletion stubs/Authlib/authlib/oauth2/client.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from typing import Any

from authlib.oauth2 import ClientAuth, OAuth2Error, TokenAuth

Expand Down Expand Up @@ -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: ...
Loading