How to automate JWT authentication in K6?
I want to get the authentication from JWT.
Currently we have npm javascript file which logins to the application using headless browser and retrieve the authentication. I believe we can not integrate npm module in K6.
Can anyone give examples of how they are doing it?
You’re right, it’d be best to avoid npm module (docs) but it’s possible to add the logic for JWT in k6 script.
Basics for authentication in k6 are here: these examples are not for JWT specifically but they include similar steps and can be used as a template.
And the full example of how to sign / encode / decode JWT in k6 script is here:
I think one of these or a combination should be sufficient to add necessary authentication.