This time I will show you how to use Postman to handle token parameter transfer, and what are the precautions for using Postman to handle token parameter transfer. The following is a practical case, let's take a look.
Problem description:
There is a login interface to obtain the token, and you must bring the token when accessing other interfaces againSolution:
1. Set the Postman environment variable (Environment) after accessing the login interface, for exampleSet the environment variable Name: token, The value is the token value in responseBody after successful access to the login interface. Please see the detailed description below for how to set it.
2. When accessing other interfaces, the token value can be directly read from the variable. The syntax for obtaining variables in Postman is: {{Variable name}}
Specific steps:
1. Introduction to the login interface
{ "status": 0, "message": "成功", "data": { "username": "cams_admin_dev", "token": "eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1MTYzNDIxMjAsInN1YiI6ImNhbXNfYWRtaW5fZGV2IiwiY3JlYXRlZCI6MTUxNjI1NTcyMDU0NywiZnVsbCI6ImNhbXNfYWRtaW5fZGV2IiwidWF1dGgiOiIvKio7QUxMIiwiYXV0aCI6InNldHRpbmdzLGNhbXNfYWRtaW4saW5kdXN0cnksYm9uZCxjYW1zSG9tZSxjb21wYW55LGFyZWEsZGV0YWlscyxjYW1zT3BlcmF0aW9uIn0.pI09X8KNoIK0fb6xC1xbrSZyg-EnUnlZ_9shmOQCRDtdIIEA5iyq3HmzgSx0ReaChEAZxkrrSRTtSXE8ZlbCTw" } }The return value contains the token value , how can this value be automatically set as a Postman environment variable after accessing the login interface?
2. After accessing the login interface, it is automatically set to the Postman environment variable
Write the following code in the Tests of the Postman software to set the environment variablepm.test("Status code is 200", function () { pm.response.to.have.status(200); }); // 把responseBody转为json字符串 var data = JSON.parse(responseBody); // 设置环境变量token,供后面的接口引用 pm.environment.set("token", data.data.token);As shown in the figure below:
3. Access other interfaces, environment variable token
As shown in red marked
1. Another interface2. Select the token type in TYPE. What I use here is Bearer Token3. Set the token value in the red marked part on the right. The format is: {{token}} to get the previous login interface. If the token is dynamically set during access, then this interface can be used. I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website! Recommended reading:
Detailed explanation of automatic refresh and parsing steps using webpack
How to build a vue2.0 boostrap project
The above is the detailed content of How to use Postman to handle token parameter transfer. For more information, please follow other related articles on the PHP Chinese website!

PDF文件作为一种通用的文件格式,被广泛应用于各种应用场景,如电子书、报表、合同等等。在开发过程中,我们常常需要对PDF文件进行生成、编辑、读取等操作。而PHP作为一种脚本语言,也能够轻松地完成这些任务。本文将介绍使用PHP处理PDF文件的方法。一、生成PDF文件生成PDF文件有许多方法,其中最常见的是使用PDF库。PDF库是一种生成PDF文档的工具,它为

登录token无效问题可以通过检查网络连接、检查token有效期、清除缓存和Cookie、检查登录状态、联系应用程序开发者和加强账号安全来解决。详细介绍:1、检查网络连接,重新连接网络或者更换网络环境;2、检查token有效期,重新获取一个新的token,或者联系应用程序的开发者;3、清除缓存和Cookie,清除浏览器缓存和Cookie,然后重新登录应用程序;4、检查登录状态。

登录token无效的解决办法有检查Token是否过期、检查Token是否正确、检查Token是否被篡改、检查Token是否与用户匹配、清除缓存或Cookie、检查网络连接和服务器状态、重新登录或请求新的Token、联系技术支持或开发人员等。详细介绍:1、检查Token是否过期,登录Token通常会设置有效期,一旦超过有效期,就会被认为无效等等。

CakePHP是一个开源的Web应用程序框架,它基于PHP语言构建,可以简化Web应用程序的开发过程。在CakePHP中,处理文件上传是一个常见的需求,无论是上传头像、图片还是文档,都需要在程序中实现相应的功能。本文将介绍CakePHP中如何处理文件上传的方法和一些注意事项。在Controller中处理上传文件在CakePHP中,上传文件的处理通常在Cont

Redis存储用户token在设计类似电商的系统时,一个常见的需求是每个页面都需要携带登录用户信息。常见的解决方法有两种:使用cookie保存使用JWT保存但如果系统中使用了Redis缓存,那么还可以有第三种解决方案–将用户token缓存在Redis中。登陆时生成一个token存入Redis//生成一个token对象,保存在redis中redisTemplate.opsForHash().put("token","user",user)

一、token登录鉴权jwt:JSONWebToken。是一种认证协议,一般用来校验请求的身份信息和身份权限。由三部分组成:Header、Hayload、Signatureheader:也就是头部信息,是描述这个token的基本信息,json格式{"alg":"HS256",//表示签名的算法,默认是HMACSHA256(写成HS256)"type":"JWT"//表示Token的类型,JWT令牌统一写为JWT}pa

CakePHP是一个流行的PHP开发框架,它可以帮助开发者快速构建高质量的Web应用程序。随着全球化的发展,越来越多的应用需要支持多语言,CakePHP也提供了相应的支持。本文将介绍CakePHP如何处理多语言。一、多语言支持多语言支持是CakePHP的一项重要功能。从版本2.0开始,CakePHP支持gettext文件格式,该

token是一种虚拟货币,它是一种用于表示用户权限、记录交易信息、支付虚拟货币的数字货币。token可以用来在特定的网络上进行交易,它可以用来购买或出售特定的虚拟货币,也可以用来支付特定的服务费用。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version
Useful JavaScript development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
