Interface OAuth2Authenticator
- All Superinterfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionAttempts to authenticate the client and returns a validAccessToken.voidclose()Closes the authenticator and releases all resources.copy()voidstart()Starts the authenticator.
-
Method Details
-
start
void start()Starts the authenticator. This will trigger the first background authentication attempt,and the result of this attempt will be returned by the next call toauthenticate(). This will also start the periodic background refresh of the access token.Calling this method on an already started authenticator has no effect.
This method never throws an exception.
-
authenticate
AccessToken authenticate()Attempts to authenticate the client and returns a validAccessToken.This method may block until the authenticator is started and the first authentication attempt is successful.
- Returns:
- a valid
AccessToken - Throws:
OAuth2Exception- if the authentication attempt failsHttpClientException- if the authentication attempt fails due to a network error
-
close
void close()Closes the authenticator and releases all resources. This will interrupt any threads waiting onauthenticate(), stop the periodic background refresh of the access token, and close the underlying HTTP client and the internal Executor (unless the executor was user-provided).- Specified by:
closein interfaceAutoCloseable
-
copy
OAuth2Authenticator copy()
-