Documentation shows setAuth() returning user and error in the return object. This is causing confusion.
Improve documentation
Documentation shows setAuth() returning user and error in the return object. This is causing confusion.
const { user, error } = supabase.auth.setAuth(access_token)
## Link
EDIT: This might be better in the supabase (document) forum, but figured a dev familiar the function should decide the right answer for what to say.
Describe the problem
setAuth returns a session object with the user null and no error property. By showing those in the return this is causing confusion for users as observed in Discord and Github. Some think it will return a valid user object. Examples: https://github.com/supabase/gotrue-js/issues/243 and https://discord.com/channels/839993398554656828/952306750369959957
Describe the improvement
Consider changing the return to session.
let session = supabase.auth.setAuth(access_token)
Or have no return.
Also comment that the function does not make a server call, sets the token in the session and clears the user object. If you need the user object then suggest calling getUser AFTER you do setAuth.