vREST supports any type of token based authentication. In the login API, authentication token can be returned from the test server as part of one of the following:
So, to use token based authentication, simply follow the steps below:
Suppose your login API returns the following response on submitting valid credentials:
{ "output": { "token": "xyz-authentication-token" } } |
Then you may extract this token via Variable Extractor sub-tab of login test case, as shown in the below snapshot:
Suppose your login API returns the authentication token as part of response headers (Response header `x-auth-token`) on submitting valid credentials. Then you may extract this token via Variable Extractor sub-tab of login test case with the help of a built-in utility method `getHeader`, as shown in the below snapshot:
here "x-auth-token" is the name of the response header which carries the authentication token. Please replace this header name with appropriate header name as per your context.