Interface OAuth2Authenticator

All Superinterfaces:
AutoCloseable

public interface OAuth2Authenticator extends AutoCloseable
  • 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 to authenticate(). 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 valid AccessToken.

      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 fails
      HttpClientException - 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 on authenticate(), 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:
      close in interface AutoCloseable
    • copy