LocalhostBrowserRedirectHandler

class LocalhostBrowserRedirectHandler(port: Int, path: String, timeoutMs: Long = DEFAULT_TIMEOUT_MS, browserLauncher: (String) -> Unit = Companion::defaultBrowserLauncher) : BrowserRedirectHandler

A BrowserRedirectHandler implementation for JVM that starts a localhost HTTP server, opens the system browser, and captures the redirect callback.

The port and path must match the redirect URI registered in the Okta admin console. For example, if registered as http://localhost:8080/callback, use port = 8080 and path = "/callback".

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.

browserLauncher

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

Constructors

Link copied to clipboard
constructor(port: Int, path: String, timeoutMs: Long = DEFAULT_TIMEOUT_MS, browserLauncher: (String) -> Unit = Companion::defaultBrowserLauncher)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun handleRedirect(url: String): String

Opens the given URL in a browser and suspends until the redirect callback is captured.