

def build_oauth_base_string(http_request, consumer_key, nonce, signaure_type, timestamp, version, next='oob', token=None, verifier=None):
    "Generates the base string to be signed in the OAuth request.\n\n  Args:\n    http_request: The request being made to the server. The Request's URL\n        must be complete before this signature is calculated as any changes\n        to the URL will invalidate the signature.\n    consumer_key: Domain identifying the third-party web application. This is\n        the domain used when registering the application with Google. It\n        identifies who is making the request on behalf of the user.\n    nonce: Random 64-bit, unsigned number encoded as an ASCII string in decimal\n        format. The nonce/timestamp pair should always be unique to prevent\n        replay attacks.\n    signaure_type: either RSA_SHA1 or HMAC_SHA1\n    timestamp: Integer representing the time the request is sent. The\n        timestamp should be expressed in number of seconds after January 1,\n        1970 00:00:00 GMT.\n    version: The OAuth version used by the requesting web application. This\n        value must be '1.0' or '1.0a'. If not provided, Google assumes version\n        1.0 is in use.\n    next: The URL the user should be redirected to after granting access\n        to a Google service(s). It can include url-encoded query parameters.\n        The default value is 'oob'. (This is the oauth_callback.)\n    token: The string for the OAuth request token or OAuth access token.\n    verifier: str Sent as the oauth_verifier and required when upgrading a\n        request token to an access token.\n  "
    params = http_request.uri.query.copy()
    params['oauth_consumer_key'] = consumer_key
    params['oauth_nonce'] = nonce
    params['oauth_signature_method'] = signaure_type
    params['oauth_timestamp'] = str(timestamp)
    if (next is not None):
        params['oauth_callback'] = str(next)
    if (token is not None):
        params['oauth_token'] = token
    if (version is not None):
        params['oauth_version'] = version
    if (verifier is not None):
        params['oauth_verifier'] = verifier
    sorted_keys = None
    try:
        sorted_keys = sorted(params.keys())
    except NameError:
        sorted_keys = params.keys()
        sorted_keys.sort()
    pairs = []
    for key in sorted_keys:
        pairs.append(('%s=%s' % (urllib.quote(key, safe='~'), urllib.quote(params[key], safe='~'))))
    all_parameters = urllib.quote('&'.join(pairs), safe='~')
    normailzed_host = http_request.uri.host.lower()
    normalized_scheme = (http_request.uri.scheme or 'http').lower()
    non_default_port = None
    if ((http_request.uri.port is not None) and (((normalized_scheme == 'https') and (http_request.uri.port != 443)) or ((normalized_scheme == 'http') and (http_request.uri.port != 80)))):
        non_default_port = http_request.uri.port
    path = (http_request.uri.path or '/')
    request_path = None
    if (not path.startswith('/')):
        path = ('/%s' % path)
    if (non_default_port is not None):
        request_path = urllib.quote(('%s://%s:%s%s' % (normalized_scheme, normailzed_host, non_default_port, path)), safe='~')
    else:
        request_path = urllib.quote(('%s://%s%s' % (normalized_scheme, normailzed_host, path)), safe='~')
    base_string = '&'.join((http_request.method.upper(), request_path, all_parameters))
    return base_string

dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/gdata/gauth.py build_oauth_base_string/original