How to globally inject multiple mandatory query parameters and auth tokens into all requests?

已回答

I am using the IntelliJ IDEA HTTP Client to debug APIs that require specific authentication and debugging parameters. For my current testing scenario, the backend bypasses full authentication if certain hidden query parameters are present.

0

Hi, at the moment, the IntelliJ IDEA HTTP Client doesn’t support globally injecting query parameters or headers into all requests automatically.
You can use HTTP Client environments and define the required auth token and bypass/debug query parameters once in an http-client.env.json, and then reference those variables in your requests.
Example
http-client.env.json
 

{
  "dev": {
    "authToken": "debug-token",
    "bypassAuth": "true",
    "trace": "true"
  }
}

HTTP request:

GET https://api.example.com/users?bypassAuth={{bypassAuth}}&trace={{trace}}
Authorization: Bearer {{authToken}}

See documentation: https://www.jetbrains.com/help/idea/http-client-variables.html#example-working-with-environment-files

0

请先登录再写评论。