Skip to content
Merged
2 changes: 1 addition & 1 deletion stubs/Authlib/METADATA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version = "1.8.0"
upstream-repository = "https://github.com/authlib/authlib"
dependencies = ["cryptography"]
# Requires a version of flask with a `py.typed` file
optional-dependencies = ["requests", "httpx2", "Flask>=2.0.0"]
optional-dependencies = ["Flask>=2.0.0", "httpx2", "requests", "types-oauthlib"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Generator
from typing import ClassVar
from typing_extensions import Never

import httpx2
Expand All @@ -23,10 +24,10 @@ class OAuth2ClientAuth(Auth, ClientAuth):
def auth_flow(self, request: Request) -> Generator[Request, Response]: ...

class AsyncOAuth2Client(_OAuth2Client, httpx2.AsyncClient):
SESSION_REQUEST_PARAMS: list[str]
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
SESSION_REQUEST_PARAMS: ClassVar[list[str]]
client_auth_class: ClassVar[type[OAuth2ClientAuth]]
token_auth_class: ClassVar[type[OAuth2Auth]]
oauth_error_class: ClassVar[type[OAuthError]]
def __init__(
self,
client_id=None,
Expand All @@ -46,10 +47,10 @@ class AsyncOAuth2Client(_OAuth2Client, httpx2.AsyncClient):
async def ensure_active_token(self, token): ... # type: ignore[override]

class OAuth2Client(_OAuth2Client, httpx2.Client):
SESSION_REQUEST_PARAMS: list[str]
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
SESSION_REQUEST_PARAMS: ClassVar[list[str]]
client_auth_class: ClassVar[type[OAuth2ClientAuth]]
token_auth_class: ClassVar[type[OAuth2Auth]]
oauth_error_class: ClassVar[type[OAuthError]]
def __init__(
self,
client_id=None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from _typeshed import Incomplete
from collections.abc import Callable
from http.cookiejar import CookieJar
from typing import Any, ClassVar, TypeVar

from authlib.oauth2.auth import ClientAuth, TokenAuth
from authlib.oauth2.client import OAuth2Client
from oauthlib.oauth2 import OAuth2Token
from requests import PreparedRequest, Response, Session
from requests._types import (
AuthType,
Expand All @@ -24,36 +26,38 @@ from ..base_client import OAuthError

__all__ = ["OAuth2Session", "OAuth2Auth"]

_PR = TypeVar("_PR", bound=PreparedRequest)

class OAuth2Auth(AuthBase, TokenAuth):
def ensure_active_token(self) -> None: ...
def __call__(self, req: PreparedRequest) -> PreparedRequest: ...
def __call__(self, req: _PR) -> _PR: ...

class OAuth2ClientAuth(AuthBase, ClientAuth):
def __call__(self, req: PreparedRequest) -> PreparedRequest: ...
def __call__(self, req: _PR) -> _PR: ...

class OAuth2Session(OAuth2Client, Session):
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
SESSION_REQUEST_PARAMS: tuple[str, ...] # type: ignore[assignment]
default_timeout: Incomplete
client_auth_class: ClassVar[type[OAuth2ClientAuth]]
token_auth_class: ClassVar[type[OAuth2Auth]]
oauth_error_class: ClassVar[type[OAuthError]]
SESSION_REQUEST_PARAMS: ClassVar[tuple[str, ...]]
default_timeout: float | tuple[float | None, float | None] | None
def __init__(
self,
client_id=None,
client_secret=None,
token_endpoint_auth_method=None,
revocation_endpoint_auth_method=None,
scope=None,
state=None,
redirect_uri=None,
token=None,
token_placement="header",
update_token=None,
leeway=60,
default_timeout=None,
client_id: str | None = None,
client_secret: str | None = None,
token_endpoint_auth_method: str | None = None,
revocation_endpoint_auth_method: str | None = None,
scope: str | None = None,
state: str | None = None,
redirect_uri: str | None = None,
token: dict[str, Any] | None = None,
token_placement: str = ...,
update_token: Callable[[OAuth2Token], None] | None = None,
leeway: int = 60,
default_timeout: float | tuple[float | None, float | None] | None = None,
**kwargs,
) -> None: ...
def fetch_access_token(self, url=None, **kwargs): ...
def fetch_access_token(self, url: str | None = None, **kwargs) -> OAuth2Token: ...
def request( # type: ignore[override]
self,
method: str,
Expand Down
13 changes: 8 additions & 5 deletions stubs/Authlib/authlib/oauth2/client.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from _typeshed import Incomplete
from collections.abc import Sequence
from typing import ClassVar

from authlib.oauth2 import ClientAuth, OAuth2Error, TokenAuth
from authlib.common.errors import AuthlibBaseError
from authlib.oauth2 import ClientAuth, TokenAuth

DEFAULT_HEADERS: Incomplete

class OAuth2Client:
client_auth_class = ClientAuth
token_auth_class = TokenAuth
oauth_error_class = OAuth2Error
client_auth_class: ClassVar[type[ClientAuth]]
token_auth_class: ClassVar[type[TokenAuth]]
oauth_error_class: ClassVar[type[AuthlibBaseError]]
EXTRA_AUTHORIZE_PARAMS: tuple[str, ...]
SESSION_REQUEST_PARAMS: list[str]
SESSION_REQUEST_PARAMS: ClassVar[Sequence[str]]
session: Incomplete
client_id: Incomplete
client_secret: Incomplete
Expand Down
Loading