auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

Bug with supabase.auth.getSessionFromUrl();

Open vincent-thomas opened this issue 4 years ago • 1 comments

Bug report

Describe the bug

When i authenticate with google the user gets authenticated and i get their credentials through supabase.auth.user(), but i can't get the user object with the supabase.auth.getSessionfromUrl function.

This bug only exists if you don't add the { storeSession: true } option in the supabase.auth.getSessionFromUrl function.

To Reproduce

This is the function thats called signIn

export const signIn = () =>
  supabase.auth.signIn(
    { provider: 'google' },
    { redirectTo: 'http://localhost:3000/auth/callback' }
  );

I just use this function at a button press like this


import {signIn} from "@core/auth";

export default function PageComponent() {

  ....

  return (
    <>
      <button onClick={signIn}>
        Sign in
      </button>
      ...
    </>
  )
}

When its redirected to the /auth/callback route. I call this function

 await supabase.auth.getSessionFromUrl();

And then this response

{
    "data": null,
    "error": {
      "message": "TypeError: Cannot read properties of undefined (reading 'api')",
      "stack": "TypeError: Cannot read properties of undefined (reading 'api')
        at GoTrueClient.js:320:39
        at Generator.next (<anonymous>)
        at GoTrueClient.js:7:1
        at new Promise (<anonymous>)
        at __awaiter (GoTrueClient.js:3:1)
        at getSessionFromUrl (GoTrueClient.js:298:1)
        at _callee$ (callback.tsx:10:40)
        at tryCatch (runtime.js:63:16)
        at Generator.invoke [as _invoke] (runtime.js:293:1)
        at Generator.next (runtime.js:118:1)"}
}

Expected behavior

What i want it to do is to redirect to the google auth page sign in, and then give me the credentials in the method:

supabase.auth.getSessionFromUrl(); // <-- this

This method is in the /auth/callback route, but for some reason i get this error

{
    "data": null,
    "error": {
      "message": "TypeError: Cannot read properties of undefined (reading 'api')",
      "stack": "TypeError: Cannot read properties of undefined (reading 'api')
        at GoTrueClient.js:320:39
        at Generator.next (<anonymous>)
        at GoTrueClient.js:7:1
        at new Promise (<anonymous>)
        at __awaiter (GoTrueClient.js:3:1)
        at getSessionFromUrl (GoTrueClient.js:298:1)
        at _callee$ (callback.tsx:10:40)
        at tryCatch (runtime.js:63:16)
        at Generator.invoke [as _invoke] (runtime.js:293:1)
        at Generator.next (runtime.js:118:1)"}
}

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: Windows 11
  • Browser Brave browser
  • Version of supabase-js: 1.29.4
  • Version of Node.js: 16.13.1

vincent-thomas avatar Feb 06 '22 13:02 vincent-thomas

Update?

vincent-thomas avatar Mar 14 '22 22:03 vincent-thomas

Closing for lack of activity and I think this has already been taken care of with the release of v2.

hf avatar Dec 30 '22 17:12 hf