Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Call Auth, get token, and share it across all checks #932

Open
fasatrix opened this issue Sep 12, 2024 · 1 comment
Open

[QUESTION] Call Auth, get token, and share it across all checks #932

fasatrix opened this issue Sep 12, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@fasatrix
Copy link

Hi,

I’m new to this and not entirely sure if this is the right place for my question, so any guidance is appreciated.

We have a basic authentication (HTTPS) endpoint that requires a username and password to retrieve a token, which is then used in the headers for subsequent API calls. Since the Auth endpoint has a throttling limit, allowing only a few requests per minute without errors, I’m looking for a way to call this endpoint just once, store the token, and make it accessible in our k6 test scripts as an environment variable.

Ideally, the token should be refreshed periodically. A script triggered by cron (or a similar scheduler) would be perfect for this. The goal is to avoid making an Auth request in every k6 script, but instead, have the token fetched periodically, stored, and reused across all scripts.

Any advice on how to set this up would be greatly appreciated.

I really appreciate any help you can provide.

@peterschretlen peterschretlen added the enhancement New feature or request label Sep 23, 2024
@peterschretlen
Copy link
Contributor

@fasatrix thanks for the question, we don't currently have a way to manage auth tokens or other secretes in this way. "secrets management" is a synthetics feature we're planning to implement, though I don't have an ETA for it.

Until then, consider using a secrets manager with an API to cache the token and then fetch it from the k6 script. For example if you're using AWS you could consider using https://grafana.com/docs/k6/latest/javascript-api/jslib/aws/secretsmanagerclient/ where you cache your token in AWS secrets manager and then use this client to fetch the token. Other secrets managers have APIs that you could use to create helper functions that operate in a similar way to this client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants