i am not completely sure of your scenario, but try this (ReadyAPI 3.63.0):
- In ReadyAPI, open the Navigator panel (left side).
- Select your Project (or any node under it).
- In the toolbar near the top choose Auth & Security → Auth Manager.
- The dialog opens with two tabs:
- Auth Repository: where you create or configure authorization profiles.
- Auth Manager: where you assign profiles to requests.
- Click the Auth Repository tab → select your Authorization Profile (e.g., OAuth 2.0).
- In the profile configuration area you’ll see 2 tabs.
Even though the UI might not label “Pre-Request” explicitly, you want to add your script in the first script block (before the token request). Here’s what to add:
// This script runs before the token request is sent
def hdrName = 'X-Tenant'
def hdrValue = 'acme'
// UI-level headers for the token call
def h = request.getRequestHeaders() ?: [:]
h[hdrName] = [hdrValue]
request.setRequestHeaders(h)
// Low-level Apache HTTP request object
def httpReq = context.getProperty('httpRequest') // org.apache.http.HttpRequest
httpReq?.removeHeaders(hdrName)
httpReq?.addHeader(hdrName, hdrValue)
- While in the Auth Repository tab, select the profile → go to Automation Scripts.
- In the first script box (the “before token retrieval” or equivalent), paste the code above.
- Return to the Profile Parameters tab. Then go to a request assigned to that profile → click Get Access Token (or run it via TestRunner) → check the HTTP log or proxy to verify the header X-Tenant: acme is included in the token call.
- If the profile type is Basic or API Key, the UI may not expose automation scripts. Automation scripting is supported primarily for OAuth 2.0 (and Azure OAuth) flows.
- If you assign the profile to a request, the token call might happen automatically, and your script needs to catch that flow.
- If your server uses a custom or non-browser token endpoint (no UI pages), you won’t use DOM scripting but you still can inject headers via the code above.
- Make sure you click Get Access Token after updating the script to trigger the token call (and header injection) immediately.
https://support.smartbear.com/readyapi/docs/en/configure-requests/authentication/authentication-types/oauth-2-0-and-oauth-2-0--azure-/automation-script.html
Adding custom header to auth profile token call | SmartBear Community
I walked through as many of the above steps as I could, but didn't check it completely.
Let me know how it goes!