Class CommonsHttpOAuthProvider

  • All Implemented Interfaces:
    java.io.Serializable, OAuthProvider

    public class CommonsHttpOAuthProvider
    extends AbstractOAuthProvider
    This implementation uses the Apache Commons HttpClient 4.x HTTP implementation to fetch OAuth tokens from a service provider. Android users should use this provider implementation in favor of the default one, since the latter is known to cause problems with Android's Apache Harmony underpinnings.
    See Also:
    Serialized Form
    • Field Detail

      • httpClient

        private transient org.apache.http.client.HttpClient httpClient
    • Constructor Detail

      • CommonsHttpOAuthProvider

        public CommonsHttpOAuthProvider​(java.lang.String requestTokenEndpointUrl,
                                        java.lang.String accessTokenEndpointUrl,
                                        java.lang.String authorizationWebsiteUrl)
      • CommonsHttpOAuthProvider

        public CommonsHttpOAuthProvider​(java.lang.String requestTokenEndpointUrl,
                                        java.lang.String accessTokenEndpointUrl,
                                        java.lang.String authorizationWebsiteUrl,
                                        org.apache.http.client.HttpClient httpClient)
    • Method Detail

      • setHttpClient

        public void setHttpClient​(org.apache.http.client.HttpClient httpClient)
      • createRequest

        protected HttpRequest createRequest​(java.lang.String endpointUrl)
                                     throws java.lang.Exception
        Description copied from class: AbstractOAuthProvider
        Overrride this method if you want to customize the logic for building a request object for the given endpoint URL.
        Specified by:
        createRequest in class AbstractOAuthProvider
        Parameters:
        endpointUrl - the URL to which the request will go
        Returns:
        the request object
        Throws:
        java.lang.Exception - if something breaks
      • sendRequest

        protected HttpResponse sendRequest​(HttpRequest request)
                                    throws java.lang.Exception
        Description copied from class: AbstractOAuthProvider
        Override this method if you want to customize the logic for how the given request is sent to the server.
        Specified by:
        sendRequest in class AbstractOAuthProvider
        Parameters:
        request - the request to send
        Returns:
        the response to the request
        Throws:
        java.lang.Exception - if something breaks
      • closeConnection

        protected void closeConnection​(HttpRequest request,
                                       HttpResponse response)
                                throws java.lang.Exception
        Description copied from class: AbstractOAuthProvider
        Called when the connection is being finalized after receiving the response. Use this to do any cleanup / resource freeing.
        Overrides:
        closeConnection in class AbstractOAuthProvider
        Parameters:
        request - the request that has been sent
        response - the response that has been received
        Throws:
        java.lang.Exception - if something breaks