K
Kinde•2mo ago
pio0otrek

Force refresh organizations

Hello Team, My scenario: - User signup and defaults to default org 🙂 - User has possibility to create organization - When he creates organization, in backgroud via webhooks I do: -- create new or -- move user to newly created org My challange: - next still see user in default organization, i have to force reauth Is there any more user friendly workaround Like to manually force refresh jwt? Or should i just take it as it is?
4 Replies
Abdelrahman Zaki - Kinde
Hey @pio0otrek, great question. The token refresh approach is the most user-friendly way to handle this. Most major SDKs include a method to refresh the user’s token without a full re-auth so the session picks up the new organisation membership. Which SDK are you using? I can share the exact refresh method for that one.
pio0otrek
pio0otrekOP•2mo ago
next.js Do i understand correctly, that using: const {refreshTokens} = getKindeServerSession(); should be enough?
IkiTg07
IkiTg07•2mo ago
Hey, sorry for jumping in. Yeah you just need to await refreshTokens() and should be good to go. You can see here : https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/#refreshtokens
Kinde docs
Next.js App Router SDK
Complete guide for Next.js App Router SDK including installation, configuration, middleware setup, route protection, and authentication integration for Next.js 13+ applications.
Abdelrahman Zaki - Kinde
Hey @pio0otrek, let me know if you need anything else. We’re here to help. Many thanks for jumping in, @IkiTg07. Really appreciate the assist.

Did you find this page helpful?