def sign_request(self, consumer, signature_method):
    params = {
      'oauth_consumer_key': consumer.key,
      'oauth_timestamp': oauth.generate_timestamp(),
      'oauth_nonce': oauth.generate_nonce(),
      'oauth_version': oauth.OAuthRequest.version,
    }
          
    # PHP OAuth library contains a bug which interferes with signing.  Since
    # some containers use this library, we will implement a workaround here.
    if self.use_body_as_signing_parameter:
      params[self.get_post_body()] = ""
    else:
      # Otherwise, use the oauth_body_hash extension to sign the request body.
      if self.post_body:
        if VERBOSE > 0:
          logging.info("post_body => %s" % str(self.post_body))
          
        body_hash = b64encode(hashlib.sha1(self.get_post_body()).digest())
        params['oauth_body_hash'] = body_hash
      
    if self.get_security_token():
      self.set_parameter("xoauth_requestor_id", None)
    
    self.set_parameters(params)
    if VERBOSE > 0:
      key, raw = signature_method.build_signature_base_string(
                     self.oauth_request, consumer, None)
      logging.info("build_signature key => %s" % key)
      logging.info("build_signature raw => %s" % raw)
      
    self.oauth_request.sign_request(signature_method, consumer, None)
Add oauth parameters and sign the request with the given method.
dataset/ETHPy150Open CollabQ/CollabQ/vendor/opensocial/http.py/Request.sign_request