Skip to content

Error on exchangeCodeForSession when setting the token key for password recovery #950

@JuanxCursed

Description

@JuanxCursed

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I was trying to work on a more detailed workflow when recovering the password, and when I was taking a look at the source code, I've found a possible bug

When the recovery token is recorded into the storage, the key stored is sb-api-auth-token-code-verifier but when the code tries to exchangeCodeForSession at line 545, ${this.storageKey}-code-verifier.
this.storageKey is a constant set into the constants.ts named STORAGE_KEY and its value is supabase.auth.token

Due to this, when exchangeCodeForSession is executed, since it doesn't find the code-verifier, I receive this error:

AuthApiError: invalid request: both auth code and code verifier should be non-empty 

To Reproduce

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

  1. Send a email password reset link
  2. Check the storage key created
  3. Click on the reset link
  4. When redirect to your site with the code query string try to execute exchangeCodeForSession with this value
  5. See the error on console

Expected behavior

Recover the session to reset the password properly

System information

  • OS: macOS
  • Browser (if applies) chrome
  • Version of supabase-js: 2.39.3
  • Version of @nuxtjs/supabase: 1.1.5
  • Version of VueJs: 3.3.8
  • Version of Node.js: 18.16.0

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthas workaroundIssue has a valid workaround.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions