I have a collection in Thunder Client. In the collection settings I setup the authentication, with Oauth 2 client credentials grant, which generates a token. The documentation describes that token is saved and will be included in the 'Authentication' header for the requests sent in the collection, and so it does. But what I want is to access that generated access token to include it in another header in some of the requests.
I tried to saved it in a variable, but I did not succeed.
- I configured the 'Tests' in the collection to 'Set Env Variable', json.access_token setTo {{access_token}} , but it does not work. It seems the Tests are not for the case when token is generated with the
Generate Token
button. - I tried to access the token by the name indicated in the OAuth 2 'Advanced Options', but it did not work either.
Either there is something really simple I'm missing, or it is not possible... I checked the documentation for Thunder Client and looked in Internet, but the closest I got was to the work around below.
As work around I created another POST request in my collection which retrieves the access token, and within the 'Tests' tab I can save the the json.access_token from the response body in a variable and use it in other requests.
But I'd still like to know if the access_token can be saved from the Generate Token
for the collection.