25

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.

enter image description here

Any help is appreciated. Thanks

Vedran
  • 1,113
  • 1
  • 17
  • 36
Rohit Khatri
  • 1,980
  • 3
  • 25
  • 45

3 Answers3

5

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".

Mahammad Adil Azeem
  • 9,112
  • 13
  • 57
  • 84
0

you can use tools like Postman or you can add authentication.SessionAuthentication to your authentication_classes

authentication_classes = [authentication.TokenAuthentication, authentication.SessionAuthentication]

so as long as you are logged in you can see the put patch and options request on the page. by this method, you are not sending any Token. use it for development purposes.

Mahdi Hamzeh
  • 289
  • 2
  • 8
-1
  • 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.
Amrit
  • 2,115
  • 1
  • 21
  • 41
  • I know how to do that in postman, but I want to use the UI of django rest framework, and need a way to set headers in the UI. – Rohit Khatri Mar 25 '17 at 07:37