예제 #1
0
def build_header_string(header_data):
    """ Builds the Authorization header for the oauth requests """
    header_string = "OAuth "
    encoded_values = []
    for key,value in sorted(header_data.items()):
        encoded_values.append('{0}="{1}"'.format(encode(key), encode(value)))
    header_string += ", ".join(encoded_values)
    return header_string
예제 #2
0
def sign_request(signature_string, consumer_secret):
    """ Applies a hash to the request data in order to sign the request """
    return hmac(encode(consumer_secret)+"&", signature_string, sha1).digest().encode('base64')[:-1]