Class OAuthRequest

java.lang.Object
com.github.scribejava.core.model.OAuthRequest

public class OAuthRequest extends Object
The representation of an OAuth HttpRequest.
  • Constructor Details

    • OAuthRequest

      public OAuthRequest(Verb verb, String url)
      Default constructor.
      Parameters:
      verb - Http verb/method
      url - resource URL
  • Method Details

    • addOAuthParameter

      public void addOAuthParameter(String key, String value)
      Adds an OAuth parameter.
      Parameters:
      key - name of the parameter
      value - value of the parameter
      Throws:
      IllegalArgumentException - if the parameter is not an OAuth parameter
    • getOauthParameters

      public Map<String,String> getOauthParameters()
    • setRealm

      public void setRealm(String realm)
    • getRealm

      public String getRealm()
    • getCompleteUrl

      public String getCompleteUrl()
      Returns the complete url (host + resource + encoded querystring parameters).
      Returns:
      the complete url.
    • addHeader

      public void addHeader(String key, String value)
      Add an HTTP Header to the Request
      Parameters:
      key - the header name
      value - the header value
    • addBodyParameter

      public void addBodyParameter(String key, String value)
      Add a body Parameter (for POST/ PUT Requests)
      Parameters:
      key - the parameter name
      value - the parameter value
    • addQuerystringParameter

      public void addQuerystringParameter(String key, String value)
      Add a QueryString parameter
      Parameters:
      key - the parameter name
      value - the parameter value
    • addParameter

      public void addParameter(String key, String value)
    • getMultipartPayload

      public MultipartPayload getMultipartPayload()
    • setMultipartPayload

      public void setMultipartPayload(MultipartPayload multipartPayload)
    • initMultipartPayload

      public void initMultipartPayload()
    • initMultipartPayload

      public void initMultipartPayload(String boundary)
    • initMultipartPayload

      public void initMultipartPayload(String subtype, String boundary)
    • initMultipartPayload

      public void initMultipartPayload(Map<String,String> headers)
    • initMultipartPayload

      public void initMultipartPayload(String boundary, Map<String,String> headers)
    • initMultipartPayload

      public void initMultipartPayload(String subtype, String boundary, Map<String,String> headers)
    • setBodyPartPayloadInMultipartPayload

      public void setBodyPartPayloadInMultipartPayload(BodyPartPayload bodyPartPayload)
    • addBodyPartPayloadInMultipartPayload

      public void addBodyPartPayloadInMultipartPayload(BodyPartPayload bodyPartPayload)
    • setPayload

      public void setPayload(String payload)
      Set body payload. This method is used when the HTTP body is not a form-url-encoded string, but another thing. Like for example XML. Note: The contents are not part of the OAuth signature
      Parameters:
      payload - the body of the request
    • setPayload

      public void setPayload(byte[] payload)
      Overloaded version for byte arrays
      Parameters:
      payload - byte[]
    • setPayload

      public void setPayload(File payload)
      Overloaded version for File
      Parameters:
      payload - File
    • getQueryStringParams

      public ParameterList getQueryStringParams()
      Get a ParameterList with the query string parameters.
      Returns:
      a ParameterList containing the query string parameters.
      Throws:
      OAuthException - if the request URL is not valid.
    • getBodyParams

      public ParameterList getBodyParams()
      Obtains a ParameterList of the body parameters.
      Returns:
      a ParameterListcontaining the body parameters.
    • getUrl

      public String getUrl()
      Obtains the URL of the HTTP Request.
      Returns:
      the original URL of the HTTP Request
    • getSanitizedUrl

      public String getSanitizedUrl()
      Returns the URL without the port and the query string part.
      Returns:
      the OAuth-sanitized URL
    • getStringPayload

      public String getStringPayload()
      Returns the body of the request (set in setPayload(java.lang.String))
      Returns:
      form encoded string
    • getByteArrayPayload

      public byte[] getByteArrayPayload()
      Returns:
      the body of the request (set in setPayload(byte[]) or in addBodyParameter(java.lang.String, java.lang.String) )
    • getFilePayload

      public File getFilePayload()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getVerb

      public Verb getVerb()
    • getHeaders

      public Map<String,String> getHeaders()
    • getCharset

      public String getCharset()
    • setCharset

      public void setCharset(String charsetName)
      Set the charset of the body of the request
      Parameters:
      charsetName - name of the charset of the request