class documentation
class CallbackHandler: (source)
Handler for OAuth callback server during federation authentication.
This class manages a local HTTP server that listens for OAuth authorization code callbacks. It validates the state using PKCE and extracts the authorization code for token exchange.
| Method | __init__ |
Undocumented |
| Async Method | listen |
Start the HTTP server on a free port. |
| Async Method | shutdown |
Shutdown the HTTP server. |
| Async Method | wait |
Wait for the authorization code to be received. |
| Property | addr |
The full address of the callback server. |
| Property | code |
The authorization code received from the OAuth callback. |
| Property | port |
The port number the server is listening on. |
| Property | state |
The PKCE state verifier used for callback validation. |
| Method | _get |
Find and bind to a free port on localhost. |
| Async Method | _handle |
Handle the OAuth callback request. |
| Async Method | _set |
Set the authorization code if the state is valid. |
| Instance Variable | _addr |
Undocumented |
| Instance Variable | _app |
Undocumented |
| Instance Variable | _code |
Undocumented |
| Instance Variable | _done |
Undocumented |
| Instance Variable | _lock |
Undocumented |
| Instance Variable | _port |
Undocumented |
| Instance Variable | _runner |
Undocumented |
| Instance Variable | _site |
Undocumented |
| Instance Variable | _state |
Undocumented |
Start the HTTP server on a free port.
Binds to localhost on a free port and starts listening for callbacks.
Wait for the authorization code to be received.
| Parameters | |
| timeout:float or None | Optional timeout in seconds. |
| Returns | |
| str or None | The authorization code or None if timed out. |
Find and bind to a free port on localhost.
| Returns | |
| tuple[int, socket.socket, str] | A tuple of (port, socket, address). |
Handle the OAuth callback request.
Extracts the authorization code and state from the query parameters, validates the state, and sets the code if valid.
| Parameters | |
request:web.Request | The incoming HTTP request. |
| Returns | |
web.Response | The HTTP response to send back. |