How to implement refresh token

I wanted to implement the refresh token logic in nextjs app router sdk , I followed the docs but wasn't able to understand the logic/implementation, would appreciate the step by step guide. Thanks
4 Replies
Oli - Kinde
Oli - Kinde6mo ago
Hey @jixxywizzy, Where did you have troubles setting up your refresh token logic? What steps did you follow in the doc? Once I know where you got stuck, I will be able to get a member of my team to help you out
jixxywizzy
jixxywizzyOP6mo ago
Requirement is to keep the access token time of 2 or 3 minutes after that refresh token should fetch new access token, which is happening but it requires a reload , it doesn't happens quietly in the background as it says in the docs. If you can give the proper step by step guide to fulfil the requirements, that would be great I'm using nextjs app router sdk and I have nestjs backend where I'm using nodejs express sdk where verifyjwt logic is implemented So for every request from the frontends I have to send the access token in the header and as I said it doesn't updates the access token in background it sends the old(expired one) access token in request and hence request gets failed. Need help in this scenario, urgently Thanks
Oli - Kinde
Oli - Kinde6mo ago
Hey @jixxywizzy, Thanks for explaining more details about your issue. I have passed on this information to a team mate of mine who is an expert in the NextJS SDK.
peteswah
peteswah6mo ago
In a route handler or server action get the refreshTokens function from getKindeSession
const {refreshTokens} = getKindeSession();
const {refreshTokens} = getKindeSession();
~ some data on the Kinde is changed (via API or UI) now call refreshTokens
await refreshTokens()
await refreshTokens()
and it should refresh. If you are calling refreshTokens from a page, it will not work
Want results from more Discord servers?
Add your server