OpenRouterOAuthLocalCallbackServer class final
A one-shot HTTP server that captures the OpenRouter OAuth callback on localhost.
Binds to 127.0.0.1:0 (any free port), serves a small success/error page,
and completes with the authorization code from the first GET /?code=...
request. The server closes itself automatically after the code is captured
or after a timeout.
The app (flutter_app) shares this class through the
openrouter_oauth_callback.dart shim; its pre-fork body carried the
gh-781 chain-safe close, which this class adopted back (issue #1996).
missingCodeTarget keeps the two 400-page hints verbatim: the CLI says
"try again in the terminal", the app "try again in the app".
Constructors
- OpenRouterOAuthLocalCallbackServer({String missingCodeTarget = 'terminal'})
- Creates a server that will bind to an ephemeral localhost port.
Properties
- callbackUrl → String?
-
The callback URL to pass to OpenRouter, or null before start.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- missingCodeTarget → String
-
The surface named in the missing-code 400 page ("terminal" / "app").
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → Future< void> - Closes the server and cancels the timeout.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
{Duration timeout = const Duration(minutes: 5)}) → Future< String> - Starts the server and returns the URL OpenRouter should redirect to.
-
toString(
) → String -
A string representation of this object.
inherited
-
waitForCode(
) → Future< String?> - Waits for the callback and returns the authorization code, or null on timeout/error.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited