vscode-restclient
vscode-restclient copied to clipboard
How to create a variable from the decoded output of the response body containing JWT accessToken?
Is it possible to create a variable from the decoded output of the response body containing JWT accessToken?
You can find the instructions in the readme:
https://github.com/Huachao/vscode-restclient#request-variables
The documentation is good. Thanks.
But the ask is valid and would be really nice to have.
In my case (getting the token from the response body, not a header), the token coming in the response, and captured in a variable, has an & encoded as &, so when sending it on the subsequent call, it's rejected because it's not a valid base64 encoded header.
@baseUrl = https://example.com/api
# @name login
POST {{baseUrl}}/api/login HTTP/1.1
Content-Type: application/x-www-form-urlencoded
name=foo&password=bar
###
@authToken = {{login.response.headers.X-AuthToken}}
The @authToken from above will have a value like ... & ..., which will be rejected in the following call, like:
# @name createComment
POST {{baseUrl}}/comments HTTP/1.1
Authorization: {{authToken}}
Content-Type: application/json
{
"content": "fake content"
}
Would be really nice if we could get the variable with the decoded value, like ... & ...