DEV Community

Discussion on: How to authenticate and protect REST API routes with JWT and refresh tokens

Collapse
 
cryxto profile image
Yohanes Bagas Ari Widatama • Edited

if you encounter problem in refresh access token where the cookie not rewrite the existing refreshToken using curl, use this :

curl -b cookie.txt -c cookie.txt --request GET \
--url http://localhost:5000/api/auth/refresh \
--cookie refreshToken="$(sed -En '/refreshToken/s/.*refreshToken\s*(.*)/\1/p' cookie.txt)"

In this command, -b cookie.txt specifies that curl should read cookies from the cookie.txt file, and -c cookie.txt specifies that curl should write cookies to the same cookie.txt file.

By placing the -b and -c options before the --url option, you ensure that curl reads the cookies from the file, sends them with the request, and writes the updated cookies back to the file after the request is completed.

Collapse
 
cryxto profile image
Yohanes Bagas Ari Widatama

by the way, thx alot for this article