handlersoauth.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:enkiWS 作者: juliettef 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号