如何在 Django 休息框架可浏览 API 中发送标头 [英] How to send headers in Django rest framework browsable API

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

问题描述

如何在 Django REST framework 可浏览的 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.它允许您为您的请求设置标头.您可以在那里设置令牌 authtoken,其中名称"为授权",值"为令牌".

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 休息框架可浏览 API 中发送标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆