'Generate OAUTH params along with signature.'

def _generate_params_with_signature(self, client_key, uri, client_secret=None, resource_owner_key=None, resource_owner_secret=None, callback_uri=None, verifier=None, http_method='GET'):

    timestamp = six.text_type(int(time.time()))
    nonce = (six.text_type(random.getrandbits(64)) + timestamp)
    oauth_params = [('oauth_nonce', nonce), ('oauth_timestamp', timestamp), ('oauth_version', '1.0'), ('oauth_signature_method', 'HMAC-SHA1'), ('oauth_consumer_key', client_key)]
    if resource_owner_key:
        oauth_params.append(('oauth_token', resource_owner_key))
    if callback_uri:
        oauth_params.append(('oauth_callback', callback_uri))
    if verifier:
        oauth_params.append(('oauth_verifier', verifier))
    key_values = [(self._escape(k), self._escape(v)) for (k, v) in oauth_params]
    key_values.sort()
    parameter_parts = ['{0}={1}'.format(k, v) for (k, v) in key_values]
    normalized_params = '&'.join(parameter_parts)
    (scheme, netloc, path, params, query, fragment) = urlparse.urlparse(uri)
    scheme = scheme.lower()
    netloc = netloc.lower()
    normalized_uri = urlparse.urlunparse((scheme, netloc, path, params, '', ''))
    base_string = self._escape(http_method.upper())
    base_string += '&'
    base_string += self._escape(normalized_uri)
    base_string += '&'
    base_string += self._escape(normalized_params)
    key = self._escape((client_secret or ''))
    key += '&'
    key += self._escape((resource_owner_secret or ''))
    key_utf8 = key.encode('utf-8')
    text_utf8 = base_string.encode('utf-8')
    signature = hmac.new(key_utf8, text_utf8, hashlib.sha1)
    sig = binascii.b2a_base64(signature.digest())[:(-1)].decode('utf-8')
    oauth_params.append(('oauth_signature', sig))
    return oauth_params
