public final class LocalServerReceiver extends Object implements VerificationCodeReceiver
Implementation is thread-safe.
Modifier and Type | Class and Description |
---|---|
static class |
LocalServerReceiver.Builder
Builder.
|
Constructor and Description |
---|
LocalServerReceiver()
Constructor that starts the server on
LOCALHOST and an unused port. |
Modifier and Type | Method and Description |
---|---|
String |
getCallbackPath()
Returns callback path used in redirect_uri.
|
String |
getHost()
Returns the host name to use.
|
int |
getPort()
Returns the port to use or
-1 to select an unused port in getRedirectUri() . |
String |
getRedirectUri()
Returns the redirect URI.
|
void |
stop()
Releases any resources and stops any processes started.
|
String |
waitForCode()
Blocks until the server receives a login result, or the server is stopped
by
stop() , to return an authorization code. |
public LocalServerReceiver()
LOCALHOST
and an unused port.
Use LocalServerReceiver.Builder
if you need to specify any of the optional parameters.
public String getRedirectUri() throws IOException
VerificationCodeReceiver
getRedirectUri
in interface VerificationCodeReceiver
IOException
public String waitForCode() throws IOException
stop()
, to return an authorization code.waitForCode
in interface VerificationCodeReceiver
null
if the server
is stopped by stop()
IOException
- if the server receives an error code (through an HTTP request
parameter error
)public void stop() throws IOException
VerificationCodeReceiver
stop
in interface VerificationCodeReceiver
IOException
public String getHost()
public int getPort()
-1
to select an unused port in getRedirectUri()
.public String getCallbackPath()
Copyright © 2011–2019 Google. All rights reserved.