depy.py 文件源码

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

项目:depy 作者: bruienne 项目源码 文件源码
def get_auth_token(self):
        """
        Retrieves an auth_session_token using DEP server token data prepared as an
        OAuth1Session() instance earlier on.
        """
        # Retrieve session auth token
        get_session = self.dep_prep('session', 'get', authsession=self.oauth)
        response = self.oauth.send(get_session)

        # Extract the auth session token from the JSON reply
        token = response.json()['auth_session_token']

        # The token happens to contain the UNIX timestamp of when it was generated
        # so we save it for later reference.
        timestamp = token[:10]

        # Roll a human-readable timestamp as well.
        ts_readable = datetime.datetime.fromtimestamp(
                      int(timestamp)).strftime(
                      '%Y-%m-%d %H:%M:%S')

        print "Token generated at %s" % ts_readable

        return token, timestamp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号