rest - IntelliJ Http client: Conditional header - Stack Overflow

admin2025-04-21  4

I want to use the Intellij Http client to do some HTTP requests. I have different environments. On one of them, I want to login with a JWT and on the other with OAuth2. Both need different headers. I want to set one of the headers based on the environment I chose, but I can find a option for that.

My request looks like this:

GET {{URL}
Authorization: {{JWTTOKEN}}
AuthorizationOAuth: Bearer {{$auth.token("oauth")}}

I couldn't find a way to only provide the Authorization header if I use environment1 and the AuthorizationOAuth header if I use environment2. Is this even possible in any way?

转载请注明原文地址:http://anycun.com/QandA/1745190458a90408.html