Skip to content
Merged
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
1 change: 0 additions & 1 deletion stubs/Authlib/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ authlib.oidc.core.grants.implicit.OpenIDImplicitGrant.validate_consent_request
# Exclude integrations dirs
# Failed to import, getting ModuleNotFoundError for third-party libs:
authlib.integrations.sqla_oauth2.*
authlib.integrations.starlette_client.*
2 changes: 1 addition & 1 deletion stubs/Authlib/METADATA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 = ["django-stubs", "Flask>=2.0.0", "httpx2", "requests", "types-oauthlib"]
optional-dependencies = ["django-stubs", "Flask>=2.0.0", "httpx2", "requests", "starlette", "types-oauthlib"]

[tool.stubtest]
mypy-plugins = ["mypy_django_plugin.main"]
Expand Down
17 changes: 13 additions & 4 deletions stubs/Authlib/authlib/integrations/starlette_client/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
from _typeshed import Incomplete
from typing import TypeVar, overload

from ..base_client import BaseOAuth, OAuthError as OAuthError
from starlette.config import Config

from ..base_client import BaseApp, BaseOAuth, OAuthError as OAuthError
from .apps import StarletteOAuth1App as StarletteOAuth1App, StarletteOAuth2App as StarletteOAuth2App
from .integration import StarletteIntegration as StarletteIntegration

_AppT = TypeVar("_AppT", bound=BaseApp)

class OAuth(BaseOAuth):
oauth1_client_cls = StarletteOAuth1App
oauth2_client_cls = StarletteOAuth2App
framework_integration_cls = StarletteIntegration
config: Incomplete
def __init__(self, config=None, cache=None, fetch_token=None, update_token=None) -> None: ...
config: Config | None
def __init__(self, config: Config | None = None, cache=None, fetch_token=None, update_token=None) -> None: ...

@overload
def register(self, name: str, overwrite: bool = False, *, client_cls: type[_AppT], **kwargs) -> _AppT: ...
@overload
def register(self, name: str, overwrite: bool = False, **kwargs): ...

__all__ = ["OAuth", "OAuthError", "StarletteIntegration", "StarletteOAuth1App", "StarletteOAuth2App"]
36 changes: 19 additions & 17 deletions stubs/Authlib/authlib/integrations/starlette_client/apps.pyi
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
from _typeshed import Incomplete
from typing import TypeAlias
from typing import Any

from starlette.datastructures import URL
from starlette.requests import Request
from starlette.responses import RedirectResponse

from ...oauth2.rfc6749.wrappers import OAuth2Token
from ..base_client import BaseApp
from ..base_client.async_app import AsyncOAuth1Mixin, AsyncOAuth2Mixin
from ..base_client.async_openid import AsyncOpenIDMixin
from ..httpx_client import AsyncOAuth1Client, AsyncOAuth2Client

_RedirectResponse: TypeAlias = Incomplete # actual type is starlette.responses.RedirectResponse

class StarletteAppMixin:
async def save_authorize_data(self, request, **kwargs) -> None: ...
async def authorize_redirect(self, request, redirect_uri=None, **kwargs) -> _RedirectResponse: ...
async def save_authorize_data(self, request: Request, **kwargs) -> None: ...
async def authorize_redirect(self, request: Request, redirect_uri: str | URL | None = None, **kwargs) -> RedirectResponse: ...

class StarletteOAuth1App(StarletteAppMixin, AsyncOAuth1Mixin, BaseApp):
client_cls = AsyncOAuth1Client
async def authorize_access_token(self, request, **kwargs): ...
async def authorize_access_token(self, request: Request, **kwargs) -> dict[str, Any]: ...

class StarletteOAuth2App(StarletteAppMixin, AsyncOAuth2Mixin, AsyncOpenIDMixin, BaseApp):
client_cls = AsyncOAuth2Client
async def logout_redirect(
self,
request,
post_logout_redirect_uri=None,
id_token_hint=None,
request: Request,
post_logout_redirect_uri: str | URL | None = None,
id_token_hint: str | None = None,
*,
state=None,
client_id=None,
logout_hint=None,
ui_locales=None,
) -> _RedirectResponse: ...
async def validate_logout_response(self, request): ...
async def authorize_access_token(self, request, **kwargs): ...
state: str | None = None,
client_id: str | None = None,
logout_hint: str | None = None,
ui_locales: str | None = None,
) -> RedirectResponse: ...
async def validate_logout_response(self, request: Request) -> dict[str, Any]: ...
async def authorize_access_token(self, request: Request, **kwargs) -> OAuth2Token: ...
Loading