[Django]-Secret API key for accessing Django REST framework

20👍

Use the TokenAuthentication class, as documented here.

You’ll also want to setup appropriate permissions, probably using the IsAuthenticated class.

Edit: Apologies – re-reading you post it looks like you want a global secret key, not a per-user one. I’d suggest a custom permission class that checks for the request header and fails if it’s not present/not correct.

7👍

There is a third party app now for this purpose called django-rest-framework-api-key.

👤yofee

Leave a comment