Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
from _typeshed import Incomplete
from collections.abc import Callable
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 Request, Response, Session
from requests.auth import AuthBase

from ..base_client import OAuthError

__all__ = ["OAuth2Session", "OAuth2Auth"]

# Inherits from requests.auth.AuthBase
class OAuth2Auth(TokenAuth):
_R = TypeVar("_R", bound=Request)

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

# Inherits from requests.auth.AuthBase
class OAuth2ClientAuth(ClientAuth):
def __call__(self, req): ...
class OAuth2ClientAuth(AuthBase, ClientAuth):
def __call__(self, req: _R) -> _R: ...

# Inherits from requests.Session
class OAuth2Session(OAuth2Client):
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
class OAuth2Session(OAuth2Client, Session):
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 = ...,
default_timeout: float | tuple[float | None, float | None] | None = None,
**kwargs,
) -> None: ...
def fetch_access_token(self, url=None, **kwargs): ...
def request(self, method, url, withhold_token=False, auth=None, **kwargs): ...
def fetch_access_token(self, url: str | None = None, **kwargs) -> OAuth2Token: ...
def request(self, method: str, url: str, withhold_token: bool = False, auth=None, **kwargs) -> Response: ...
Loading