Why would Django Rest Framework token authentication work in Postman but not in browser

348 Views Asked by At

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?

1

There are 1 best solutions below

0
Mahammadhusain kadiwala On

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

Django rest framework supported only session based and basic authentication.