Rest框架可浏览API中发送标头

Rest框架可浏览API中发送标头

本文介绍了如何在Django Rest框架可浏览API中发送标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在Django REST框架可浏览的API视图中发送标题,我通过匹配令牌来验证调用,并在标题中进行传递.我可以在邮递员中使用该API,并且效果很好,但是我想提供一些输入信息,以便将访问令牌放在Django REST框架的可浏览API上.

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.

为提供参考,例如我要在其中输入标题,我附上了UI图片.

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

感谢您的帮助.谢谢

推荐答案

检查 modheader .它允许您设置请求的标题.您可以在此处设置令牌身份验证令牌,其中名称"为授权",值"为令牌".

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

在我的情况下,我使用的是rest_framework_JWT,因此,授权标头类似于"JWT your_token".

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

这篇关于如何在Django Rest框架可浏览API中发送标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 07:43