5

I wanted a simple api authentication route using django-rest-framework and 'django-rest-auth`. The register part is working fine as confirmed by the default django admin console and i can also see the users. Unluckily the api authentication keeps on returning me with error

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

Currently the configuration that i have for my allauth is as follows

# all-auth configuration
ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_AUTHENTICATION_METHOD="email"
ACCOUNT_USERNAME_REQUIRED=False
ACCOUNT_EMAIL_VERIFICATION="none"
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE=False

# CORS Configuration
CORS_ORIGIN_ALLOW_ALL=True

I am unsure what part I am missing. Please guide me in the right direction. There are no errors and the response code is 400. The credentials are correct as verified from django admin panel. Thanks in advance

Update

The problem is somewhat with email. I commented the configuration out and tried to generate a token with username and password. That works without any error.

Art
  • 2,836
  • 4
  • 17
  • 34
georoot
  • 3,557
  • 1
  • 30
  • 59
  • Have you checked [here](http://stackoverflow.com/questions/28347200/django-rest-http-400-error-on-getting-token-authentication-view)? – Fine Jan 18 '17 at 12:39
  • @Fian just checked all of the conditions are true as mentioned at that answer. – georoot Jan 18 '17 at 12:44
  • Do you use valid email? You can try to debug it [here](https://github.com/Tivix/django-rest-auth/blob/master/rest_auth/serializers.py#L71). – Raz Jan 19 '17 at 10:55
  • same problem here, any solution found? – Mohamed El-Saka Apr 07 '17 at 04:32

1 Answers1

14

You need to add these backends to settings.py file

AUTHENTICATION_BACKENDS = (
   "django.contrib.auth.backends.ModelBackend",
   "allauth.account.auth_backends.AuthenticationBackend"
)
Art
  • 2,836
  • 4
  • 17
  • 34
Mohamed El-Saka
  • 732
  • 10
  • 13