#3437·locust

Allow a way to refresh the auth header before each request

Author: David-HariCreated Jun 30, 2026Updated Sep 15, 2026
Labelsfeature request

Prerequisites

Description

For testing an API that uses OAuth for authentication, I need to refresh the access token before it expires. Since that could happen at any time, I need to be able to check before each request is sent.

FastHttpSession exposes an auth_header property that you can set before a request is sent. However, it is cumbersome to check and set that in every test. Ideally, I would like to be able to pass a function or lambda to the session object and have it call that to get the auth header before making a request. Similar thing should be possible for HttpSession.

Alternatively, if anyone has a better idea on how to refresh auth tokens that would be much appreciated. thanks