Class OAuth2Processor

    • Constructor Detail

      • OAuth2Processor

        OAuth2Processor(OAuth2Configuration oauth2Configuration, OkHttpClient client)
      • OAuth2Processor

        OAuth2Processor(OAuthConfig oAuthConfig)
        Constructs a new OAuth2Processor.
        Parameters:
        oAuthConfig - the OAuth configuration
      • OAuth2Processor

        OAuth2Processor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client)
        Constructs a new OAuth2Processor with designated AbstractOAuthClient and OkHttpClient.
        Parameters:
        oAuthConfig - the OAuth configuration
        oAuthClient - the AbstractOAuthClient used as OAuth credentials
        client - the OkHttpClient used to make requests
    • Method Detail

      • setScope

         final Unit setScope(String scope)
      • setState

         final Unit setState(String state)
      • setSecret

         final Unit setSecret(String secret)
      • authenticate

         abstract OAuth2Token authenticate()

        Starts the OAuth 2.0 authentication process.

        Returns:

        The obtained OAuth2Token if the process was successful, otherwise null.

      • cancelAuthentication

         abstract Unit cancelAuthentication()

        Cancels the ongoing authentication process. Does nothing if there was no ongoing authentication.

      • refresh

        @WorkerThread() OAuth2Token refresh(OAuth2Token token)

        Refreshes the given OAuth 2.0 token.

        Parameters:
        token - The OAuth2Token to be refreshed
        Returns:

        The refreshed OAuth2Token if the process was successful.

      • isAuthenticated

         final Boolean isAuthenticated(HttpUrl url)

        Checks whether the request has session or not, this is called from OAuth2Interceptor to determine whether or not to add the bearer token in the header.