client.py 文件源码

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

项目:timed-backend 作者: adfinis-sygroup 项目源码 文件源码
def login(self, username, password):
        """Authenticate a user.

        :param str username: Username of the user
        :param str password: Password of the user
        :raises:             exceptions.AuthenticationFailed
        """
        data = {
            'data': {
                'attributes': {
                    'username': username,
                    'password': password
                },
                'type': 'obtain-json-web-tokens',
            }
        }

        response = self.post(reverse('login'), data)

        if response.status_code != status.HTTP_200_OK:
            raise exceptions.AuthenticationFailed()

        self.credentials(
            HTTP_AUTHORIZATION='{0} {1}'.format(
                api_settings.JWT_AUTH_HEADER_PREFIX,
                response.data['token']
            )
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号