Skip to content

pywry.auth.callback_server

Local HTTP callback server for OAuth2 redirect handling in native mode.


OAuthCallbackServer

pywry.auth.callback_server.OAuthCallbackServer

OAuthCallbackServer(host: str = '127.0.0.1', port: int = 0)

Ephemeral localhost HTTP server for capturing OAuth2 redirects.

PARAMETER DESCRIPTION
host

Bind address (default "127.0.0.1").

TYPE: str DEFAULT: '127.0.0.1'

port

Port number (0 for auto-assign).

TYPE: int DEFAULT: 0

Initialize the callback server.

Attributes

redirect_uri property

redirect_uri: str

Get the redirect URI for this callback server.

RETURNS DESCRIPTION
str

The full redirect URI (e.g. http://127.0.0.1:54321/callback).

Functions

start

start() -> str

Start the callback server on a daemon thread.

RETURNS DESCRIPTION
str

The redirect URI to use with the OAuth2 provider.

wait_for_callback

wait_for_callback(timeout: float = 120.0) -> dict[str, Any] | None

Block until the callback is received or timeout expires.

PARAMETER DESCRIPTION
timeout

Maximum seconds to wait (default 120).

TYPE: float DEFAULT: 120.0

RETURNS DESCRIPTION
dict or None

Callback parameters (code, state, error, error_description) or None if timeout expired.

stop

stop() -> None

Force-shutdown the callback server.