我已经尝试了两种记录的身份验证方法,但两者都产生403 Forbidden,detail:"未提供身份验证凭据。"
auth = coreapi.auth.TokenAuthentication(
scheme='Token', token='token')
和
auth = coreapi.auth.BasicAuthentication(
username='user',
password='password')
url = 'http://127.0.0.1:8000/schema/'
client = coreapi.Client(auth=auth)
schema = client.get(url)
答案 0 :(得分:0)
根据coreapi.auth.BasicAuthentication
和coreapi.auth.TokenAuthentication
here的源代码,您需要按如下方式实例化身份验证对象:
auth = coreapi.auth.TokenAuthentication(
scheme='Token', token='token', domain='domain')
或
auth = coreapi.auth.BasicAuthentication(
username='user',
password='password',
domain='domain'
)