0

I have a Django REST framework API that uses TokenAuthentication. In Postman, I can authenticate with the API using a token and make requests successfully. However, when I try to use the browsable API in my web browser, I get an "Authentication credentials were not provided" error.

I have tried including the token in the "Authorization" header, as well as passing it as a query parameter, but neither of these solutions work. I have also made sure that the TokenAuthentication class is included in my DEFAULT_AUTHENTICATION_CLASSES.

I have seen some old posts suggesting that TokenAuthentication does not work with the browsable API and that I need to use SessionAuthentication instead, but I believe this issue has been resolved in recent versions of Django REST framework.

Is there a way to use TokenAuthentication with the browsable API in Django REST framework, or do I need to use SessionAuthentication instead? If the former, what am I missing in my setup to make it work?

Please let me know if there is any specific code that would help and I'll update my question?

werberger
  • 1
  • 3
  • have you read the docs https://www.django-rest-framework.org/api-guide/authentication/ – Tanveer Ahmad Mar 16 '23 at 05:16
  • Have now, thanks. Don't think it changes anything though. My project is in line with what it says as I understand it. Further more, I am able to successfully authenticate through Postman. It is only when I'm in the browser, navigating the API. – werberger Mar 16 '23 at 11:47

1 Answers1

0

Because Django rest framework browsable api not provided passing token input.

Django rest framework supported only session based and basic authentication.