authentication.py 文件源码

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

项目:edx-drf-extensions 作者: edx 项目源码 文件源码
def authenticate(self, request):
        if not self.get_user_info_url():
            logger.warning('The setting OAUTH2_USER_INFO_URL is invalid!')
            return None

        auth = get_authorization_header(request).split()

        if not auth or auth[0].lower() != b'bearer':
            return None

        if len(auth) == 1:
            raise exceptions.AuthenticationFailed('Invalid token header. No credentials provided.')
        elif len(auth) > 2:
            raise exceptions.AuthenticationFailed('Invalid token header. Token string should not contain spaces.')

        return self.authenticate_credentials(auth[1].decode('utf8'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号