Class OAuth20Service

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class OAuth20Service
    extends OAuthService
    • Constructor Detail

      • OAuth20Service

        public OAuth20Service​(DefaultApi20 api,
                              java.lang.String apiKey,
                              java.lang.String apiSecret,
                              java.lang.String callback,
                              java.lang.String scope,
                              java.lang.String state,
                              java.lang.String responseType,
                              java.lang.String userAgent,
                              HttpClientConfig httpClientConfig,
                              HttpClient httpClient)
    • Method Detail

      • sendAccessTokenRequestSync

        protected OAuth2AccessToken sendAccessTokenRequestSync​(OAuthRequest request)
                                                        throws java.io.IOException,
                                                               java.lang.InterruptedException,
                                                               java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getAccessTokenAsync

        public java.util.concurrent.Future<OAuth2AccessToken> getAccessTokenAsync​(java.lang.String code)
      • getAccessTokenAsync

        public java.util.concurrent.Future<OAuth2AccessToken> getAccessTokenAsync​(java.lang.String code,
                                                                                  java.lang.String pkceCodeVerifier)
      • getAccessToken

        public OAuth2AccessToken getAccessToken​(java.lang.String code)
                                         throws java.io.IOException,
                                                java.lang.InterruptedException,
                                                java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getAccessToken

        public OAuth2AccessToken getAccessToken​(java.lang.String code,
                                                java.lang.String pkceCodeVerifier)
                                         throws java.io.IOException,
                                                java.lang.InterruptedException,
                                                java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getAccessToken

        public java.util.concurrent.Future<OAuth2AccessToken> getAccessToken​(java.lang.String code,
                                                                             OAuthAsyncRequestCallback<OAuth2AccessToken> callback,
                                                                             java.lang.String pkceCodeVerifier)
        Start the request to retrieve the access token. The optionally provided callback will be called with the Token when it is available.
        Parameters:
        code - code
        callback - optional callback
        pkceCodeVerifier - pkce Code Verifier
        Returns:
        Future
      • createAccessTokenRequest

        protected OAuthRequest createAccessTokenRequest​(java.lang.String code)
      • createAccessTokenRequest

        protected OAuthRequest createAccessTokenRequest​(java.lang.String code,
                                                        java.lang.String pkceCodeVerifier)
      • refreshAccessTokenAsync

        public java.util.concurrent.Future<OAuth2AccessToken> refreshAccessTokenAsync​(java.lang.String refreshToken)
      • refreshAccessToken

        public OAuth2AccessToken refreshAccessToken​(java.lang.String refreshToken)
                                             throws java.io.IOException,
                                                    java.lang.InterruptedException,
                                                    java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • createRefreshTokenRequest

        protected OAuthRequest createRefreshTokenRequest​(java.lang.String refreshToken)
      • getAccessTokenPasswordGrant

        public OAuth2AccessToken getAccessTokenPasswordGrant​(java.lang.String uname,
                                                             java.lang.String password)
                                                      throws java.io.IOException,
                                                             java.lang.InterruptedException,
                                                             java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getAccessTokenPasswordGrantAsync

        public java.util.concurrent.Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync​(java.lang.String uname,
                                                                                               java.lang.String password)
      • getAccessTokenPasswordGrantAsync

        public java.util.concurrent.Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync​(java.lang.String uname,
                                                                                               java.lang.String password,
                                                                                               OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
        Request Access Token Password Grant async version
        Parameters:
        uname - User name
        password - User password
        callback - Optional callback
        Returns:
        Future
      • createAccessTokenPasswordGrantRequest

        protected OAuthRequest createAccessTokenPasswordGrantRequest​(java.lang.String username,
                                                                     java.lang.String password)
      • getAccessTokenClientCredentialsGrantAsync

        public java.util.concurrent.Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrantAsync()
      • getAccessTokenClientCredentialsGrant

        public OAuth2AccessToken getAccessTokenClientCredentialsGrant()
                                                               throws java.io.IOException,
                                                                      java.lang.InterruptedException,
                                                                      java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getAccessTokenClientCredentialsGrant

        public java.util.concurrent.Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrant​(OAuthAsyncRequestCallback<OAuth2AccessToken> callback)
        Start the request to retrieve the access token using client-credentials grant. The optionally provided callback will be called with the Token when it is available.
        Parameters:
        callback - optional callback
        Returns:
        Future
      • createAccessTokenClientCredentialsGrantRequest

        protected OAuthRequest createAccessTokenClientCredentialsGrantRequest()
      • getVersion

        public java.lang.String getVersion()
        Returns the OAuth version of the service.
        Specified by:
        getVersion in class OAuthService
        Returns:
        OAuth version as string
      • signRequest

        public void signRequest​(java.lang.String accessToken,
                                OAuthRequest request)
      • getAuthorizationUrlWithPKCE

        public AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE​(java.util.Map<java.lang.String,java.lang.String> additionalParams)
      • getAuthorizationUrl

        public java.lang.String getAuthorizationUrl()
        Returns the URL where you should redirect your users to authenticate your application.
        Returns:
        the URL where you should redirect your users
      • getAuthorizationUrl

        public java.lang.String getAuthorizationUrl​(java.util.Map<java.lang.String,java.lang.String> additionalParams)
        Returns the URL where you should redirect your users to authenticate your application.
        Parameters:
        additionalParams - any additional GET params to add to the URL
        Returns:
        the URL where you should redirect your users
      • getAuthorizationUrl

        public java.lang.String getAuthorizationUrl​(PKCE pkce)
      • getAuthorizationUrl

        public java.lang.String getAuthorizationUrl​(java.util.Map<java.lang.String,java.lang.String> additionalParams,
                                                    PKCE pkce)
      • createRevokeTokenRequest

        protected OAuthRequest createRevokeTokenRequest​(java.lang.String tokenToRevoke,
                                                        TokenTypeHint tokenTypeHint)
      • revokeTokenAsync

        public java.util.concurrent.Future<java.lang.Void> revokeTokenAsync​(java.lang.String tokenToRevoke)
      • revokeTokenAsync

        public java.util.concurrent.Future<java.lang.Void> revokeTokenAsync​(java.lang.String tokenToRevoke,
                                                                            TokenTypeHint tokenTypeHint)
      • revokeToken

        public void revokeToken​(java.lang.String tokenToRevoke)
                         throws java.io.IOException,
                                java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • revokeToken

        public void revokeToken​(java.lang.String tokenToRevoke,
                                TokenTypeHint tokenTypeHint)
                         throws java.io.IOException,
                                java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • revokeToken

        public java.util.concurrent.Future<java.lang.Void> revokeToken​(java.lang.String tokenToRevoke,
                                                                       OAuthAsyncRequestCallback<java.lang.Void> callback)
      • revokeToken

        public java.util.concurrent.Future<java.lang.Void> revokeToken​(java.lang.String tokenToRevoke,
                                                                       OAuthAsyncRequestCallback<java.lang.Void> callback,
                                                                       TokenTypeHint tokenTypeHint)
      • extractAuthorization

        public OAuth2Authorization extractAuthorization​(java.lang.String redirectLocation)
      • getResponseType

        public java.lang.String getResponseType()
      • getState

        public java.lang.String getState()