请求授权无法正常工作

时间:2018-09-11 13:08:19

标签: python-3.x

我正在尝试使用以下内容:

auth = request.authorization
if not auth or not metrites.check( auth.username, auth.password ):
    return metrites.authenticate()

在模块模型中,我具有:

def check( username, password ):
    # This function is called to check if a username/password combination is valid
    return username == 'nikos' and password == '*****'


def authenticate():
    # Sends a 401 response that enables basic auth
    return Response( 'Credentials of a registered user required!', 401, {'WWW-Authenticate': 'Basic realm="User!"'} )

但是,每次我输入用户/密码组合时,它都无法正确接受它,并且在反驳我。

我有什么问题吗?

0 个答案:

没有答案