How to send headers in Django rest framework browsable API

元气小坏坏 提交于 2019-12-10 12:32:46

问题


How can I send headers in Django REST framework browsable API view, I am authenticating calls by matching a token and that is passed in headers. I can use that API in the postman and it's working great, but I want to give inputs for putting access token on the browsable API of Django REST framework.

For reference like where I want the inputs for headers, I'm attaching a picture of the UI.

Any help is appreciated. Thanks


回答1:


Check modheader. It allows you to set headers for your request. You can set the token authtoken there where "Name" would be "Authorization" and "Value" would be "Token ".

In my case, I was using rest_framework_JWT so, Authorization headers were like "JWT your_token".




回答2:


  • In you postman select Post method and in Headers of request write Authorization for key and Token bd8877272b3384341d063d1 for value. Use you token generated for each user.
  • Or you can also enter username and password instead of token in Headers in postman.


来源:https://stackoverflow.com/questions/39695187/how-to-send-headers-in-django-rest-framework-browsable-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!