【发布时间】:2019-09-03 09:37:04
【问题描述】:
对于django rest framework,我使用的是来自here 的django-rest-framework-simplejwt。
根据给出的指南,我的settings.py REST_FRAMERWORK 应该是这样的:
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
),
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
],
}
现在,当我像这样在CURL 的帮助下调用 api /api/token/ 时:
curl -X POST -H "Content-Type: application/json" -d '{"username": "aami", "password": "ooma"}' http://127.0.0.1:8000/api/token/
我收到以下错误:
curl -X POST -H "Content-Type: application/json" -d '{"username": "aami", "password": "ooma"}' http://127.0.0.1:8000/api/token/
而服务器端的日志是:
错误请求:/api/token/ [2019 年 4 月 12 日 15:01:02]“POST /api/token/HTTP/1.1”400 75
我遵循了指南中提到的内容,但我仍然无法找出问题所在。
【问题讨论】:
-
如果错误是
no active account with the given credentials,你似乎没有传递正确的username和password,或者username不存在。 -
您是如何创建用户的?你能展示这段代码吗?
标签: python django django-rest-framework django-rest-framework-simplejwt