Hello,
Does anyone know the best way to set a global variable with the respond token for my authentication. I want to call the global variable toke to be used on other calls. I need to store the bearer token for other calls. At this type I have my authentication call and storing the token in a variable. Thanks!
Please remember that token is persisted only at runtime. If you want to persist token permanently (for different test case(suite) execution), you have to save it into permanent memory (file, database, …).
est Cases/Advance examples/SaveToken FAILED because (of) org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/Users/fespinoza/Katalon%20Studio/Jira%20API%20Tests%20with%20Katalon%20Studio/Scripts/Advance%20examples/SaveToken/Script1533310109253.groovy: 25: unable to resolve class JsonSlurper
I am not sure what your question is. To authorize your API requests, you need:
- authentication endpoint (which usually returns authorization token in response)
- parse this response using JsonSlurper (get token itself)
- put token into Authorization HTTP header for your endpoints
Hey, thanks for responding.
I got 2 out of 3… but for #3, I need that token to be apply to a global variable automatically… there’s got to be a way in Katalon. Postman has a easy config for it. And my token that is returned is dynamic… it expires within 1 day and obviously a new one is generated after sending the login endpoint.
authentication endpoint (which usually returns authorization token in response)
-2) parse this response using JsonSlurper (get token itself)
3)- put token into Authorization HTTP header for your endpoints
Guys,
I’m still trying to apply the Token respond value to the globalVariable automatically after each test run. i created a globalvariable and have value as empty string… would like to have new token applied to globalVariable everytime I run the endpoint to get new token… so all my api tests can get that token and execute.
would appreciate anyone that can help me set this up.
Hi Dude,
I actually have not tested or tried this yet. I just use postman for API tests. But no, I did not find the “short” answer to this problem. I think this is a gap in Katalon platform where there is no intuitive way of doing it without bunch of custom keywords or coding.