tests.py 文件源码

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

项目:pyconjp-website 作者: pyconjp 项目源码 文件源码
def get_signature(self, uri, method='GET', body=''):
        """Return a dictionary with the API key and API get_signature
        to be sent for the given request."""
        # What time is it now?
        timestamp = timegm(datetime.datetime.now(tz=pytz.UTC).timetuple())

        # Calculate the base string to use for the signature.
        base_string = unicode(''.join((
            self.auth_key.secret,
            unicode(timestamp),
            method.upper(),
            uri,
            body,
        ))).encode('utf-8')

        # Return a dictionary with the headers to send.
        return {
            'HTTP_X_API_KEY': self.auth_key.auth_key,
            'HTTP_X_API_SIGNATURE': sha1(base_string).hexdigest(),
            'HTTP_X_API_TIMESTAMP': timestamp,
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号