Use apifox to configure global token


首先安装好apifox软件,附上官方下载地址[官网](https://www.apifox.cn/)。

1. Interface import

First you need to create your own project.
![Insert image description here](https://img-blog.csdnimg.cn/aa668669e3c0496a96fc7396665fa341.png
Enter your own project, click the "Import Data" button, click the "New Data Source" button
Insert image description here
to configure the data source parameters (the prerequisite is an accessible data source URL), you can create a new module in the interface part, try not to put all the interfaces Under the root directory.
Insert image description here
Once completed, click Import Now. If the service is normal, you can import the interface in the project. Take a screenshot of the interface sample I imported earlier.
Insert image description here

2. Configure global token

The Token method is to put the login credentials in the interface request parameters (usually placed in the Header). Common methods include Basic Auth, Bearer Token, API Key, etc.

Instructions:

Method 1. Set authorization information through Auth globally (root directory), group (group settings), and interface (document editing page), supporting the following multiple authorization types

Insert image description here
Bearer Token method
Insert image description here
API Key method
Insert image description here

Method 2. Manually write the token into the Header or other corresponding parameters (it is recommended to use environment variables to store the token). Example:

Bearer Token : Set a Header named Authorization and set the value to

Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9yJpZCI6...

Or use environment variables and set the value to Bearer { {AUTH_TOKEN}}

Method 3. Set global parameters in the environment uniformly. Global parameters will be automatically added when all interfaces are running, eliminating the need to manually set each interface.

(over)

Guess you like

Origin blog.csdn.net/bacawa/article/details/129528232