0


Postman使用技巧之Authorization使用

Authorization设置位置:

在这里插入图片描述

postman里面的介绍:

The authorization header will be automatically generated when you send the request. Learn more about authorization

授权头将在发送请求时自动生成。了解有关授权的更多信息:https://learning.postman.com/docs/sending-requests/authorization/

例如basic-auth格式的:https://learning.postman.com/docs/sending-requests/authorization/#basic-auth

Basic auth

Basic authentication involves sending a verified username and password with your request. In the request Authorization tab, select Basic Auth from the Type dropdown list.

Basic Auth

Enter your API login details in the Username and Password fields—for additional security you can store these in variables.

In the request Headers, you will see that the Authorization header is going to pass the API a Base64 encoded string representing your username and password values, appended to the text "Basic " as follows:

Basic <Base64 encoded username and password>

Basic Auth Encoded

理解

即Authorization中的信息被被自动拼接到head中格式为:'Basic ’ 加上 'Username:Password’转成Base_64 的字符串。(注意Basic 后面有个空格)

Authorization ='Basic '+'Username:Password':Base_64

案例

在这里插入图片描述

填写Username、Password后会自动添加到请求头中。

在这里插入图片描述
案例中的编码转换:

window.btoa('RFC_DMS_PO:D202110MS')//编码
window.atob("UkZDX0RNU19QTzpEMjAyMTEwTVM=")// 解码

在这里插入图片描述


拓展

js实现基于Base64的编码及解码:https://blog.csdn.net/weixin_42420703/article/details/81384901
用JS进行Base64编码、解码:https://www.jianshu.com/p/14437764eff3


本文转载自: https://blog.csdn.net/weixin_41287260/article/details/120940985
版权归原作者 秦时明月之君临天下 所有, 如有侵权,请联系我们删除。

“Postman使用技巧之Authorization使用”的评论:

还没有评论