public class AuthenticationCallbackServer extends java.lang.Object implements AuthenticationListener
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_AUTH_PAGE
Default HTML page that twitch.tv will send the access_token to
|
static java.lang.String |
DEFAULT_FAILURE_PAGE
Default HTML page that shows auth error's to user
|
static java.lang.String |
DEFAULT_SUCCESS_PAGE
Default HTML page that shows auth success to
|
| Constructor and Description |
|---|
AuthenticationCallbackServer(int port)
Constructor that will use default HTML views for output.
|
AuthenticationCallbackServer(int port,
java.net.URL authPage,
java.net.URL failurePage,
java.net.URL successPage)
Constructor with user specified HTML views to output.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getAccessToken()
Get the access token if one exists.
|
AuthenticationError |
getAuthenticationError()
Get the auth error if it failed.
|
boolean |
hasAuthenticationError()
Check if there was an authentication error
|
boolean |
isRunning()
Check to see if server is running.
|
void |
onAccessTokenReceived(java.lang.String token)
Called when a twitch.tv authentication access token has been received.
|
void |
onAuthenticationError(java.lang.String error,
java.lang.String description)
An authentication error occurred.
|
void |
start()
Start the server and listen for auth callbacks from twitch.
|
void |
stop()
Stops the server.
|
public static final java.lang.String DEFAULT_AUTH_PAGE
public static final java.lang.String DEFAULT_FAILURE_PAGE
public static final java.lang.String DEFAULT_SUCCESS_PAGE
public AuthenticationCallbackServer(int port)
port - Network port to receive requests onpublic AuthenticationCallbackServer(int port,
java.net.URL authPage,
java.net.URL failurePage,
java.net.URL successPage)
port - Network port to receive requests onauthPage - HTML page that twitch.tv will send the access_token tofailurePage - HTML page that shows auth error to usersuccessPage - HTML page that shows auth success to userpublic void start()
throws java.io.IOException
java.io.IOException - if an I/O error occurs while waiting for a connection.public void stop()
public boolean isRunning()
true if server is running. false otherwisepublic void onAccessTokenReceived(java.lang.String token)
AuthenticationListeneronAccessTokenReceived in interface AuthenticationListenertoken - twitch.tv authentication access tokenpublic void onAuthenticationError(java.lang.String error,
java.lang.String description)
AuthenticationListeneronAuthenticationError in interface AuthenticationListenererror - Error namedescription - Error descriptionpublic java.lang.String getAccessToken()
null otherwisepublic AuthenticationError getAuthenticationError()
null otherwisepublic boolean hasAuthenticationError()
true if an error exists, false otherwise