credentials.py 文件源码

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

项目:PyAPNs2 作者: Pr0Ger 项目源码 文件源码
def _get_or_create_topic_token(self, topic):
        # dict of topic to issue date and JWT token
        token_pair = self.__topicTokens.get(topic)
        if token_pair is None or self._is_expired_token(token_pair[0]):
            # Create a new token
            issued_at = time.time()
            token_dict = {
                'iss': self.__team_id,
                'iat': issued_at,
            }
            headers = {
                'alg': self.__encryption_algorithm,
                'kid': self.__auth_key_id,
            }
            jwt_token = jwt.encode(token_dict, self.__auth_key,
                                   algorithm=self.__encryption_algorithm,
                                   headers=headers).decode('ascii')

            self.__topicTokens[topic] = (issued_at, jwt_token)
            return jwt_token
        else:
            return token_pair[1]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号