Class LocalServerReceiver (1.34.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
Type Description
String

getHost()

public String getHost()

Returns the host name to use.

Returns
Type Description
String

getPort()

public int getPort()

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

Returns
Type Description
int

getRedirectUri()

public String getRedirectUri()

Returns the redirect URI.

Returns
Type Description
String
Exceptions
Type Description
IOException

stop()

public void stop()

Releases any resources and stops any processes started.

Exceptions
Type Description
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
Type Description
String

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

Exceptions
Type Description
IOException

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