繁体   English   中英

使用仅电子邮件方法通过django-allauth和django-rest-auth进行身份验证时出现400错误

[英]400 error when using email only method for authentication using django-allauth and django-rest-auth

我正在尝试使用django-rest-auth和django-allauth设置身份验证。 该用户存在于数据库中,我可以登录django管理站点。 当我尝试使用rest-auth / login /端点发布电子邮件/密码登录时,收到400错误,响应如下:

{
    "non_field_errors": [
        "Unable to log in with provided credentials."
    ]
}

我按照此处的说明进行操作: http : //django-allauth.readthedocs.io/en/latest/configuration.html#configuration

在我的设置文件中,我具有以下内容:

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_AUTHENTICATION_METHOD = 'email' 

如果我注释掉上面的三行并使用相同的端点,但是添加用户名,它将起作用。 它似乎仅不适用于仅电子邮件模式。

谢谢你的帮助!

我遇到了同样的问题,可以通过放置正确的身份验证后端来解决。 这是我的设置:

ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True 

AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend"
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM