'Get an OAuth signature to be used in signing a request'

def get_oauth_signature(self, request):

    if (self.signature_method == SIGNATURE_PLAINTEXT):
        return signature.sign_plaintext(self.client_secret, self.resource_owner_secret)
    (uri, headers, body) = self._render(request)
    collected_params = signature.collect_parameters(uri_query=urlparse.urlparse(uri).query, body=body, headers=headers)
    logging.debug('Collected    params:    {0}'.format(collected_params))
    normalized_params = signature.normalize_parameters(collected_params)
    normalized_uri = signature.normalize_base_string_uri(request.uri)
    logging.debug('Normalized    params:    {0}'.format(normalized_params))
    logging.debug('Normalized    URI:    {0}'.format(normalized_uri))
    base_string = signature.construct_base_string(request.http_method, normalized_uri, normalized_params)
    logging.debug('Base    signing    string:    {0}'.format(base_string))
    if (self.signature_method == SIGNATURE_HMAC):
        sig = signature.sign_hmac_sha1(base_string, self.client_secret, self.resource_owner_secret)
    elif (self.signature_method == SIGNATURE_RSA):
        sig = signature.sign_rsa_sha1(base_string, self.rsa_key)
    else:
        sig = signature.sign_plaintext(self.client_secret, self.resource_owner_secret)
    logging.debug('Signature:    {0}'.format(sig))
    return sig
