Hi <@498057949541826571> For refreshing the session , I am able to use the same refresh token multip...
k
Hi @rp_st For refreshing the session , I am able to use the same refresh token multiple times for getting new access token if I pass that as Authorization header Whereas if I pass same refresh token twice as cookie then it says Token theft detected and on third time it says : Unauthorized Can you please tell why the flow differs in both cases that is Authorziation header and cookie ?
r
hey @krrishan it should not make a difference. In general, you can continue to use a refresh token multiple times, until you use the new access / refresh token at least one. After which, the old refresh token will not work anymore. When doing the test, double check that in cookie based, the only token you are sending is the refresh token cookie and not the access token cookie
k
I already checked that So there should be same flow right from Auth header and cookie based But there seems a issue
r
It is the same flow
Send me the curl command you are trying in each case
k
curl --location --globoff --request POST '{{host}}/core/api/v1/auth/session/refresh' \ --header 'rid: session' \ --header 'Cookie: sRefreshToken=xI2iqzfXTzwAIKAxkDNwOh1bXJ2RHNq/tEUozygBwuFD3f+2poQzHTidIaO8s8KHUI1oOktde2Vdc5PZYLC0l1XaiMrc7ugZIcodXm1ruk2gWL4tuhO+m/Kzza6ntA0xSUWdf5fTDye3iFrqp9mSWKy86S+Ddnn3Gww07btQdgb+ohxmIkm5l/I6Plg0Y3JpUpdGOK6FSlwqOVqAh9AOzmamFCnoWX87l7RUuN6Jd4eD/WFiXsrPBtDnDgwzTcjEVddFlY9o9a4WJBg5NpZK.829d4375d60698fe06f11f4f3047b0fcb6052eeb3d700808e29e856336ee2462.V2'
curl --location --globoff --request POST '{{host}}/core/api/v1/auth/session/refresh' \ --header 'rid: session' \ --header 'Authorization: Bearer CBMDQedvvHnYk/AEq8De73mHCcbI0EsRr7t0x6p+UXdDXZv0JS7nu25LssNDZ5XhVElPJPpTIQUfiwzChpIhUIvM3YEtpbo22f5S1QujpyklmdXJ4yToAexBIWz7Fg/zUOt/kypS/Nf8HhKz5yJSjPoBS83Y0xOXr5KVjbltPwEmPP4o3XNey8lyIVvkPPx57pH6FgKt62cFBWvFf9cPAb5wimfzo1HU014zZMhhgPFsJu3b1CzYoWCJH75VON1wvIAN08akdIiwFRho99Sw.7583a3dbe9d996d4f3a82979cea87a62140fa1aaeb9c5867139573dc213bfab5.V2'
r
Now can you copy the cookie curl on the terminal and run it multiple times?
k
On second time I get token theft detected
r
Using the same refresh token? Do you how any customisations in the refresh api?
k
yes
r
What are the customisations?
k
r
If you remove these customisations and try, to make the curl calls, what happens?
k
The cookie flow is fine I guess Using same refresh token should give the error But why it is not happening when we share it as Auth Header
r
Using the same refresh token should not give the error, unless the new access token has been used at least once
So the cookie one is behaving weirdly.
So can you try and remove the customisations and see?
k
Ok
Getting this error Authorization is set to NoAuth
r
I have no idea what u mean. Sorry
Can u remove the customisations and try the curl command again
k
In first time getting access token and refresh token as response header
I have removed the customizations
r
Can u make a video explaining the issue?
I can’t reproduce it
k
Sure
r
Please use curl command only in the video.
Not postman.
k
curl --location --request POST 'http://localhost:3331/core/api/v1/auth/session/refresh' \ --header 'rid: session' \ --header 'Cookie: sRefreshToken=BaQZ5b6skJSajS+CNH7dMWo8fRWkydYqB5OBQ5P7V73C/vq9ZrwmzSeZ7NUckhsOasle7A8K7y5WjVetd46sMYroT8gf/tWVX5/lumVCNSRe0gQCazF2sxqPTOR5Rq896HTwYN1iLx+5L27VOULKDsl7SbA91q6VckAnvUIwhm3hLY1wx0eMVKsaqb62HxJJ8sfdkO4waDmtrY+2S8EQXXwpZOKeMQB/Zj8vU/ha5jCKtxwwQPh/5bDkwV9feiRscuN94Y6Bz4v1mrSqwsCb.9bbada6773de8745d4de2c59bb997a7cdc8f1a1a908dc8b0ab9095d5217a5b3d.V2'
r
please check the video.
it doesn't actually have your terminal showing
and in the video, please also enable backend sdk debug logging and show its output each time you call the API
k
I have attached the video Steps taken : 1. Generated a new access token and refresh token by login 2. Called refresh session api by using generated refresh token in step 1 => got new access token and refresh token 3. re called the same refresh session api without any change => response : token theft detected
r
please see the video...
anyway, ill try and help if i have time this week.
k
Sorry for inconvience Sending another video
check this one please
There are no customizations added for refresh session api
Hope it helps
r
can you just try it using curl?
As i had said..
k
It is the same curl which is shared with you
r
Try it on our demo app?
Generate one using npx create-supertokens-app@latest
If you can reproduce it on that, it will help. Cause I really can’t reproduce it. So can’t help much
k
In demo app on UI the refresh token is automatically updated with a new one
Can you confirm if you are using the older refresh token only during the second time ?
r
I am using the older one
Don’t use the ui in the demo app. Use postman or curl
And try and reproduce the issue
Ideally just use curl
Cause even with postman, the tokens are auto updated
k
Can you share me the curl or the link that you are using ? I could not find in docs
r
You can see it from chrome network tab. Google it.
82 Views