SupabaseS
Supabase4y ago
Bob

NodeJS Backend - updateUserById

I try to do the following(use-case 1):

const {data: {user, error}} = await supabase.auth.getUser(jwt);

const resp = await supabase.auth.admin.updateUserById(user.id,{ app_metadata: { isBeta: true } })

First Call for auth.getUser(jwt) works fine, second call for aut.admin.updateUserById(...) isn't working and I receive back a 401 that I'm not authorized and yes I use the service role in backend.

When I then try to do onlny as example the following(use-case 2):

const resp = await supabase.auth.admin.updateUserById(<USER_ID>,{ app_metadata: { isBeta: true } })

It works fine and the app_metadata gets updated correctly. Can somebody tell me why "use-case 1" above isn't working correctly or how I can debug on that?
Was this page helpful?