djangodjango-rest-frameworkdjango-authenticationdjango-rest-knox

Django REST Knox Authentication Issues


I've completed the development work on a Django REST API using Knox-Rest. It works great in my development environment but after moving it to the Prod environment, it authenticates users and returns a token back. Then using Postman, to test the API, I execute a GET using the returned token, I get a 401 error, Credentials Not Provided.

Looking at the "knox_authtoken" table, I see separate rows for each login. On the same table in development, I just see one row per user. I believe the answer to why it's not working is related to what I'm seeing on the table but I'm not sure what it's telling me.

All of the code is identical so it's likely in the setup but I can't seem to track it down. So anyone with some experience with the Django Knox-REST API that might have some ideas, I'd really appreciate it.


Solution

  • If Django is behind an Apache Webserver you'll need to enable WSGIPassAuthorization