【Postman登陆权限】http的请求添加cookie,使用interceptor拦截浏览器发送的请求
文章目录
要使用postman测试开发的接口时,遇到了登陆权限的问题,本项目的权限是根据cookie中的某个值来做的判断,那么就需要在发送post请求的时候附带cookie内容
发送的http请求时,附带 cookie参数
- 通过在chrome中查看线上的接口调用信息,发现登陆权限是通过cookie中的session来确定的,这样就需要把这条cookie在postman中设置出来,才能在postman中测试post请求。
- 点击按钮,弹出cookie设置的窗口
- 输入domin的名称
- 保存domin
- 添加具体的cookie参数,每一条都要在这里添加一下
- 前面的cookie的name,后面的是value
- 保存该domin下的这一条cookie
通过interceptor拦截请求
- 拦截器的好处是,不需要手动填写所有参数,而是直接截取到某个http请求的左右参数设置
- 点击该按钮,弹出拦截器相关设置窗口
- 点击
interceptor按钮 - 点击
ON打开拦截器,此时右侧的应该出现CONNECTED的绿色小点,如果是UNCONNECTED的灰色小点,可以参考文档 - 设置在哪里保存拦截的请求
- 对拦截的请求做筛选
常见问题
拦截器是 UNCONNECTED 的灰色小点
- 官方提到了这样的解决方案
-
核心内容是:
-
The cookies and domains will be populated automatically. Can you confirm the following:
- Chrome is open, and has the Interceptor extension installed (v0.2.26)
谷歌浏览器是打开状态,且已经安装Interceptor扩展 - You’ve completed the installation steps for the bridge
已经完成安装bridge - The Interceptor Status isn’t updating to ‘Interceptor Connected’ even after restarting Chrome
重启谷歌浏览器后,Interceptor应用,处于 连接中 的状态
- Chrome is open, and has the Interceptor extension installed (v0.2.26)
- Interceptor 是一个用于拦截chorme浏览器的http请求的拦截器,可以把相关请求发送给postman软件。
- Interceptor Bridge 是用来建立浏览器和postman软件之间信息连接通道的一个小应用,需要手动安装。
-
- 根据该方案,就可以使得
UNCONNECTED的灰色小点变成CONNECTED的绿色小点

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论