Class LocalServerReceiver (1.32.1)

public final class LocalServerReceiver implements VerificationCodeReceiver

OAuth 2.0 verification code receiver that runs an HTTP server on a free port, waiting for a redirect with the verification code.

Implementation is thread-safe.

Inheritance

java.lang.Object > LocalServerReceiver

Constructors

LocalServerReceiver()

public LocalServerReceiver()

Constructor that starts the server on #LOCALHOST and an unused port.

Use Builder if you need to specify any of the optional parameters.

Methods

getCallbackPath()

public String getCallbackPath()

Returns callback path used in redirect_uri.

Returns
TypeDescription
String

getHost()

public String getHost()

Returns the host name to use.

Returns
TypeDescription
String

getPort()

public int getPort()

Returns the port to use or -1 to select an unused port in #getRedirectUri().

Returns
TypeDescription
int

getRedirectUri()

public String getRedirectUri()

Returns the redirect URI.

Returns
TypeDescription
String
Exceptions
TypeDescription
IOException

stop()

public void stop()

Releases any resources and stops any processes started.

Exceptions
TypeDescription
IOException

waitForCode()

public String waitForCode()

Blocks until the server receives a login result, or the server is stopped by #stop(), to return an authorization code.

Returns
TypeDescription
String

authorization code if login succeeds; may return null if the server is stopped by #stop()

Exceptions
TypeDescription
IOException

if the server receives an error code (through an HTTP request parameter error)