Does anyone know if this has been fixed in some re...
# help
l
Does anyone know if this has been fixed in some recent updates? Planning to add authentication via Discord in one of projects sometime soon, so would be great if there wouldn't be a need to always ask people for the credentials and permissions 😄 https://github.com/supabase/gotrue-js/issues/131
n
Hello @laznic! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
🆕 Provider refresh token to Supabase session data
s
I submitted a PR to the auth helpers to help address this problem in nextjs projects. Basically the refresh token is now persisted to an HTTPonly cookie same as the auth and refresh tokens, so you can grab that value inside your getServerSideProps functions to make requests to the Discord API outside of your client. https://github.com/supabase-community/supabase-auth-helpers/blob/next/src/nextjs/handlers/callback.ts
n
Provider refresh token to Supabase session data
s
not sure if that solves your problem, for me I needed the provider token inside of a client application and during SSR. If you're trying to save that token for a bot service to use, that's going to require a different solution I think
l
Thanks for the reply! Yeah, I could probably sort this with cookies if I did SSR stuff myself, however I'm currently planning to work on an SPA 😅 probably have to test it out to see if the provider token is returned in the client side authentication and then do some own tricks to refresh the token with Discord..
s
The provider token is in the session after the initial response on sign in, but not when the session is refreshed. So you can save it to your clients state as soon as they successfully log in.
It will only be there if they log in with discord, not if they use an alternative like an email/password assuming you’ve set up both
More specifically you’ll need to hook into the onAuthStateChange from the supabase client and it will be on the session object when there is a SIGNED_IN event https://github.com/supabase/gotrue-js/blob/50141610ad4b071eee722e9657a0921f41b29a1f/src/GoTrueClient.ts#L489
l
Cheers!