usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
26.54k stars 1.22k forks source link

Cannot bind a post-request token variable #2954

Open sroziewski opened 2 months ago

sroziewski commented 2 months ago

I have checked the following:

Describe the bug

I have the request to http://localhost:8080/rest/oauth/token and I want the respone to be stored in bearerToken variable. In the previous bruno version I could put the expression in Vars bruno tab res.body.access_token Now, the value is not present when I try to use it in a different api call.

How could I achieve to store the bearer token value in this bearerToken variable?

.bru file to reproduce the bug

No response

Screenshots/Live demo link

image

image

Ryaryu commented 2 months ago

I managed that at version 1.27.0 by creating the header

Authorization: Bearer {{bearerToken}}

sroziewski commented 1 month ago

The thing is that the access_token value is not captured by the script expr res.body.access_token. How have you managed to take the value into the bearerToken variable?

AxelKlemm commented 1 month ago

Hi @sroziewski, I just ran into the same problem and was able to resolve it by turning off safe mode. Are you by any chance running in safe mode as well?

In safe mode the whole response object doesn't seem to exist for the post response variables expressions, just getting undefined.

sroziewski commented 1 month ago

Yes, That's it!