oauthlib: Fix annotations for oauthlib.oauth2.RequestValidator (#11417)

This commit is contained in:
David Salvisberg
2024-02-16 14:46:32 +01:00
committed by GitHub
parent 8a38ae62fb
commit 9b260a59cc

View File

@@ -1,8 +1,23 @@
from typing import Any
from collections.abc import Mapping
from typing import Any, Literal, TypedDict
from typing_extensions import NotRequired
from oauthlib.common import Request
from oauthlib.oauth2.rfc6749.clients import Client
class _BearerToken(TypedDict):
token_type: Literal["Bearer"]
access_token: str
expires_in: int
scope: NotRequired[str]
refresh_token: NotRequired[str]
state: NotRequired[str]
class _AuthorizationCode(TypedDict):
code: str
state: NotRequired[str]
nonce: NotRequired[str]
log: Any
class RequestValidator:
@@ -24,9 +39,9 @@ class RequestValidator:
def invalidate_authorization_code(self, client_id: str, code: str, request: Request, *args, **kwargs) -> None: ...
def revoke_token(self, token: str, token_type_hint: str, request: Request, *args, **kwargs) -> None: ...
def rotate_refresh_token(self, request: Request) -> bool: ...
def save_authorization_code(self, client_id: str, code: str, request: Request, *args, **kwargs) -> None: ...
def save_token(self, token: dict[str, int | str], request: Request, *args, **kwargs) -> None: ...
def save_bearer_token(self, token: dict[str, int | str], request: Request, *args, **kwargs) -> str: ...
def save_authorization_code(self, client_id: str, code: _AuthorizationCode, request: Request, *args, **kwargs) -> None: ...
def save_token(self, token: Mapping[str, object], request: Request, *args, **kwargs) -> object: ...
def save_bearer_token(self, token: _BearerToken, request: Request, *args, **kwargs) -> object: ...
def validate_bearer_token(self, token: str, scopes: list[str], request: Request) -> bool: ...
def validate_client_id(self, client_id: str, request: Request, *args, **kwargs) -> bool: ...
def validate_code(self, client_id: str, code: str, client: Client, request: Request, *args, **kwargs) -> bool: ...