Possible Duplicate:
Implementaion HMAC-SHA1 in python
`I am attempting to do some OAuth authentication with python, but my oauth_signature keeps getting rejected. Python 3 is pretty new to me, so can someone tell me what is wrong with this code:
api_key = 'string'
api_secret = 'another_string'
sig_key = api_secret + '&' + api_key
hmac_alg = hmac.new(sig_key.encode('utf-8'), sig_base_str.encode('utf-8'),hashlib.sha1)
signature_base = base64.b64encode(hmac_alg.digest())
url = url_base + '?' + 'oauth_signature=' + urllib.parse.quote(str(signature_base.decode('utf-8')),'') + '&' + str(param_str)
param_str is a &
delimited string of my input parameters. The HTTP service seems to be reading that fine as it will change the output response based on what i asked for. It just keeps rejecting my signature. I think hmac is the culprit.