LocalhostBrowserRedirectHandler

constructor(port: Int, path: String, timeoutMs: Long = DEFAULT_TIMEOUT_MS, successResponse: String = DEFAULT_SUCCESS_RESPONSE, browserLauncher: (String) -> Unit = Companion::defaultBrowserLauncher)

Parameters

port

the port to listen on. Must match the port in the registered redirect URI.

path

the expected callback path. Must match the path in the registered redirect URI.

timeoutMs

the maximum time in milliseconds to wait for the redirect. Defaults to 5 minutes.

successResponse

the raw HTTP response written back to the browser after the callback is captured. Defaults to DEFAULT_SUCCESS_RESPONSE, a plain HTML page telling the user to close the window. Override to show custom branding or to issue a redirect, e.g.: "HTTP/1.1 302 Found\r\nLocation: https://app.example.com/done\r\n\r\n".

browserLauncher

opens the given URL in a browser. Defaults to Desktop.browse.