How can I implement JWT access/refresh token flow with trpc

Lets say the access token has expiry of 1d and refresh token of 7d. When the access token expires the server will return 401 and will request for new access token. If it's past 7 days of login, the app should log out the user. Usually with axios I create an axios interceptor. What's the ideal way to do that in trpc. Any example of working code would be highly appreciated. Thanks!
5 Replies
JulieCezar
JulieCezar7mo ago
What are you using for Auth?
Saurav Biswas
Saurav Biswas6mo ago
Plain old jwt (no third party)
JulieCezar
JulieCezar6mo ago
Define Procedures | tRPC
A procedure is a function which is exposed to the client, it can be one of:
JulieCezar
JulieCezar6mo ago
here you have where you define the function which will allow the execution of the "protected-procedure" So looking at this example, your best bet would just be to put the token into the request header, then try to decode, and execute only if everything is ok 👍
barry
barry6mo ago
Wouldn't call it plain old lol, nothing old or plain about it, also not a standard at all, it's not meant for website authentication.
Want results from more Discord servers?
Add your server