当前位置:网站首页>What about the interface that needs to be logged in first when using the apipost test interface (based on cookies)?

What about the interface that needs to be logged in first when using the apipost test interface (based on cookies)?

2022-06-10 10:58:00 zyf20010801

Developing in the background 、 When debugging the interface , There are often interfaces that require login to request .

such as : Get login user's favorite list , here , We need to simulate the login state for interface debugging . Pictured :

today , Let's explain the use of ApiPost Environment variables of , Solve the interface dependency that needs to be logged in first and then requested .

ApiPost brief introduction :

ApiPost It's a support team collaboration , And can directly generate the API debugging 、 Management tools . It supports simulation POST、GET、PUT Etc , Is the back-end interface developer or front-end 、 A rare tool for interface testers .

Download address :https://console.apipost.cn/register?utm_source=10009

Using environment variables , First request the login interface , Then request the subsequent interface

1、 First request the login interface :

In order to be in landing mode , You need to request the login interface first , This is to simulate the user's login behavior , Get the required login parameters ( Here is Cookie).

Return the login interface PHPSESSID( This is SessionID,PHPSESSID Is aimed at PHP As a back-end interface SessionID Variable name , Variable names in other languages may be different ) Set as environment variable .

2、 Then return to the collection interface , Click on 【 send out 】 The triangle next to the button , choice 【 belt Cookie】, Input PHPSESSID={{login_var}}.

This is to use the login interface to return Cookie Falsifying a request PHPSESSID.

Pictured :

3、 Next send, You can see my collection list .

principle :

utilize ApiPost send out Cookie, Make the server recognize the logged in user's Cookie.

原网站

版权声明
本文为[zyf20010801]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101047234394.html