The Web API data source can now run a JavaScript pre-request script before every data stream request, so you can connect to APIs with authentication flows that don't fit standard Basic, Digest, OAuth 2.0 or JWT Bearer options.
Enable scripting on the data source
Turn on "Pre-request script" in the Web API data source configuration to show the Secrets and script fields. The script runs once before each request, so a single configuration covers every data stream that uses the data source.
Store credentials securely
Define key-value pairs under Secrets and access them in your script via the secrets object. Click the padlock next to a value to encrypt it when stored — recommended for API keys, client secrets and authentication tokens.
Handle token exchange and signed requests
Your script can read and modify the request url, headers and body before it's sent. A writable state object lets you cache values such as access tokens between requests, stored encrypted, so you can fetch a token once and refresh it only when it expires. That makes it possible to support flows like exchanging a signed token for a short-lived access token, or calculating a request signature per call.
image