supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
3.26k stars 270 forks source link

supabaseAuthClient.auth.getUser not working on v2.42.5 #1025

Closed yunpaik closed 6 months ago

yunpaik commented 6 months ago

Bug report

Describe the bug

When calling await supabaseAuthClient.auth.getUser() in the edge function, the following error is returned even though the correct jwt token was provided.

{
  data: { user: null },
  error: AuthSessionMissingError: Auth session missing!
    at https://esm.sh/v135/@supabase/auth-js@2.63.1/esnext/auth-js.mjs:2:29430
    at _._useSession (https://esm.sh/v135/@supabase/auth-js@2.63.1/esnext/auth-js.mjs:2:27513)
    at eventLoopTick (ext:core/01_core.js:64:7)
    at async _._getUser (https://esm.sh/v135/@supabase/auth-js@2.63.1/esnext/auth-js.mjs:2:29103)
    at async https://esm.sh/v135/@supabase/auth-js@2.63.1/esnext/auth-js.mjs:2:28966 {
    __isAuthError: true,
    name: "AuthSessionMissingError",
    status: 400,
    code: undefined
  }
}

This issue only happens on v2.42.5. The same code works perfectly fine on v.2.42.4.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Run await supabaseAuthClient.auth.getUser() in the edge function with correct jwt token

Expected behavior

I should be able to get user session without any issue

christophemenager commented 6 months ago

I confirm I have searched the Docs, GitHub Discussions, and Discord.

Really? :)

Duplicate of:

GaryAustin1 commented 6 months ago

Going to leave this open for now (even though duplicate) as for some reason the fix made in auth-js has not been released here in supabase-js.

This issue is impacting users of edge functions still currently.

kangmingtay commented 6 months ago

We've made the fix in supabase/supabase-js#1029 so it should be available in supabase-js v2.42.7, thanks for reporting this!

NickG-NZ commented 6 months ago

We've made the fix in supabase/supabase-js#1029 so it should be available in supabase-js v2.42.7, thanks for reporting this!

@kangmingtay Still getting this issue (caused by upgrading from 2.38.4 to 2.43.2)

I'm actually getting it in a NextJS route-handler. But seems to be essentially the same problem, although the solution of explicitly passing the JWT isn't relevant given the supabase ssr client uses cookies.

Can make a separate issue if needed

Tynopia commented 5 months ago

We've made the fix in supabase/supabase-js#1029 so it should be available in supabase-js v2.42.7, thanks for reporting this!

@kangmingtay Still getting this issue (caused by upgrading from 2.38.4 to 2.43.2)

I'm actually getting it in a NextJS route-handler. But seems to be essentially the same problem, although the solution of explicitly passing the JWT isn't relevant given the supabase ssr client uses cookies.

Can make a separate issue if needed

I think i have the same issue

ThisIsRahmat commented 5 months ago

I also have this same issue with my web app. My web app is builtwith Remix framework

I only see the error:AuthSessionMissingError: Auth session missing! when I try to get my user using: supabase.auth.getUser(); I am able to sign up and login successfully but when I go to fetch the newly logged in user, all I get is null.

Additionally I am using supabase from the sever side, supabase/ssr and not supabase/js

NickG-NZ commented 5 months ago

I've created a new issue here supabase/auth-js#948

sbhatm1213 commented 1 month ago

Facing this error still AuthSessionMissingError: Auth session missing! at http://localhost:3000/static/js/bundle.js:79331:20

Steps followed - (1) Add Client ID and Secret on Supabase Google Auth Provider - Done (2) Add Javascript origin - Done - http://localhost:3000/ (3) Add Redirect URI - Done - http://localhost:3000/auth/v1/callback and https://my-domain.supabase.co/auth/v1/callback (4) Add code for onAuthStateChange - Done (5) Try using const { data: { session } } = await supabase.auth.getSession() - Done - Doesn't work (6) Try using const { data: { user } } = await supabase.auth.getUser() - Done - Doesn't work (7) Try with different gotrue-js version - Done - "@supabase/supabase-js": { "@supabase/gotrue-js": "2.43.1" } (8) Try on Firefox - Done - This works fine , so on Chrome is the problem

Same issue even with Azure

Although login happens, cannot get the session/user