I am sure there is an easy enough way to do what I need.
After successful login, the authentication token from the server arrives in the body of response wrapped into a JSON message. It looks like this:
{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1OTNlYWVlOTYxZDU3ZjQ1N2IwNjM4YTgiLCJpYXQiOjE0OTczNTAzODYsImV4cCI6MTQ5NzM2ODM4Nn0.yuRehK1Afu5u9x_jFsvdCnPesczBV12oE16Ifv4kUdI"}
I need to parse that "eyJ0e...........UdI" string, and do 2 things with it:
1. Ensure that every request from this point forward (until virtual user logs out) has a header:
Authorization: Bearer eyJ0e.......UdI
2. Set 2 cookies: one to the same value as above, and another using the user name used during login.
Based on some research I have performed in the help system, it appears I should be using the JavaScript API to achieve this. Is this correct?
If so, I could use a bit of help with determining which JS calls to make in order to:
a. parse the token from the JSON message
b. set the header for every request going forward
c. set cookies
d. unset the header from (b) once user has logged out
Any ideas?
-------------------------------------------------------------------------------------------------
My progress so far:
a. I have followed the steps in NeoLoad documentation, and created a Variable Extractor. I parse into variable called token, from the body of the response.
Remaining parts:
b, c, and d.