thunder-client-support icon indicating copy to clipboard operation
thunder-client-support copied to clipboard

Fetch x-csrf-token header support

Open bensonrlee opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. Environment: v1.18.7 Using HTTP GET request with a header x-csrf-token with a value of "Fetch" is expected to fetch a CSRF token from the server. Right now, it does not throw any error or warning. Simply, the response payload contains an x-csrf-token header but empty value.

Describe the solution you'd like Please support retrieving CSRF token from a web server using the GET method via the x-csrf-token header.

Describe alternatives you've considered Tested using postman and the csrf token was retrieved and included in the response payload instead of an empty csrf key.

Implementation: None yet.

bensonrlee avatar Aug 23 '22 05:08 bensonrlee

Hi @bensonrlee

Is it not your server issue?

what is the extension supposed to do?

can you provide any sample api for me to test and understand the problem

rangav avatar Aug 23 '22 08:08 rangav

Hello @rangav ,

Had it been a server issue, I would expect the problem to show on all clients like postman and other clients. So, far I tested in 3 clients, and the other 2 behaved as expected. The thunder client is the only one that exhibited the problem.

I'd love to provide you a sample API to use but it is behind a firewall so you'd probably have some difficulty accessing it.

Is there any debug utility or anything that I can use instead that may potentially help in troubleshooting?

bensonrlee avatar Aug 23 '22 21:08 bensonrlee

We have vscode setting Request Log change the option to Advanced then you can request details in the output window, will be useful to debug request

rangav avatar Aug 23 '22 22:08 rangav

@bensonrlee Did you decoded the XSRF-TOKEN value from URL to string before use in the request?

glaucomorais avatar Sep 14 '22 06:09 glaucomorais

I confirmed...

The value of the xsrf-token in Thunder Client is URL encoded (At Cookies tab from request response to /sanctum/csrf-cookie). When saving it to environment (or set in the X-XSRF-TOKEN header) you must be decoded to string before use.

See my comment in a similar issue: https://github.com/rangav/thunder-client-support/issues/629#issuecomment-1246288807

glaucomorais avatar Sep 14 '22 06:09 glaucomorais

I am closing this issue, feel free to reopen if needed

rangav avatar Apr 01 '23 04:04 rangav