Anybody have any trouble using Supabase server sid...
# javascript
a
Anybody have any trouble using Supabase server side? I'm passing in my user's access token and calling
supabaseClient.auth.setAuth(access_token)
, but I get
null
for the return value of
user
every time with no
error
being thrown..?
g
setAuth just changes the access_token.
Copy code
setAuth(access_token: string): Session {
    this.currentSession = {
      ...this.currentSession,
      access_token,
      token_type: 'bearer',
      user: null,
    }
I'd try: const { user, error } = await supabase.auth.api.getUser( access_token) after it... But I don't do stuff on a server so not positive...
a
Oh I see! I'd bet there's no session on the server. Is there a way to manually set the access_token for each request?
g
I think that is what setAuth is doing, just setting the token for requests. It does not make a database call at all. You said you were getting the user access token to pass to it.
a
Ok so I just ran that command and it works! So now, I just gotta figure out how to set the current session/user on my server...?
Yeah so on my server,
setAuth
isn't actually doing anything.
user
keeps returning null...
g
setAuth just sets the header so you can make database calls as that user token, I believe. If you need the actual user data then the getUser should return that.
a
Hmm. Ok let me try that again.
g
Check user coming back from getUser with your token.
a
Ok
user
came back valid. We're heading in the right direction. I'm trying to set this query up real quick in order to validate the
setAuth
method
g
I just did a issue report on setAuth Docs.... https://github.com/supabase/gotrue-js/issues/247
a
That's awesome! Thanks a ton. I was able to get everything up and running properly. Thank you so much for the help!