© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•13mo ago•
7 replies
allisonee

SSR server requests at the same time not updating user metadata

I am using supabase with nextJS, and attempting to refresh a provider token (in this case, github for us) when the provider token expires. I am storing the provider token in the
user.user_metadata
user.user_metadata
that supabase returns from getUser(). The issue is, following the docs, I am not getting the updated user metadata when calling
await supabase.auth.getUser();
await supabase.auth.getUser();
after a successful refresh of a token, and re-storking it with
updateUser
updateUser
. More details below:

I am getting supabase c/p from the docs (photo attached)

Ex error: I get 4 simultaneous server requests that require a provider token. Since the provider token for those will all be expired given the token for a given user has the same expiration date, I've created a server lock system that attempts the refresh on one of those requests, while the others wait and poll to see if a new provider token is on the user.

I see that the refresh succeeds
Successfully refreshed provider token for user:
Successfully refreshed provider token for user:
, band store the new provider token in
await supabase.auth.updateUser
await supabase.auth.updateUser
in the attached image.

Then I release, the lock, which allows the rest of the 3 requests to check for the new user.
const supabase = await createClient();
const { data: { user: finalUser } } = await supabase.auth.getUser();
const supabase = await createClient();
const { data: { user: finalUser } } = await supabase.auth.getUser();


However, the user returned has the old provider token.

My suspicion is it's not actually going to the server to grab the user, becuase i see this warning in the logs at this time, but i'm not calling
getSession
getSession
anywhere in my code.
Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server.
Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server.


Or is it because getUser is server, but updateUser shouldn't be used here? Should I be storing the token in a DB instead?
CleanShot_2025-01-22_at_14.55.28.png
CleanShot_2025-01-22_at_15.04.37.png
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

user_metadata
SupabaseSSupabase / help-and-questions
4y ago
Should I authenticate the user with Firebase and Supabase at the same time?
SupabaseSSupabase / help-and-questions
4y ago
Using Auth and Functions at the same time
SupabaseSSupabase / help-and-questions
3y ago
Supabase sends OTP and Magic Links at the same time!
SupabaseSSupabase / help-and-questions
4mo ago