def auth_sign( self, normalised_url, ordered_params, token_secret = '', method_get = False ):
# note: create signature see https://dev.twitter.com/oauth/overview/creating-signatures
params_to_sign = enki.libutil.urlencode( ordered_params )
oauth_signature_string = ''
if method_get:
oauth_signature_string = 'GET&' + percent_encode( normalised_url ) + '&' + percent_encode( params_to_sign )
else:
oauth_signature_string = 'POST&' + percent_encode( normalised_url ) + '&' + percent_encode( params_to_sign )
key = percent_encode( settings.secrets.CLIENT_SECRET_TWITTER ) + '&' + token_secret
hmac_hash = hmac.new( key, oauth_signature_string, hashlib.sha1 )
oauth_signature = base64.b64encode( hmac_hash.digest())
return oauth_signature
评论列表
文章目录