Skip to content

signInWithOAuth Should Throw Errors #1693

@aress31

Description

@aress31

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

Currently, when attempting to use OAuth with Google as the provider, the error property of the OAuthResponse does not contain any value, even when the user is not registered. Instead, the error details are embedded in the returned URL, such as:

http://localhost:8888/login?to=%2F%3Ferror%3Daccess_denied%26error_code%3D422%26error_description%3DSignups%20not%20allowed%20for%20this%20instance

The error information should be properly returned within the relevant error property to allow developers to handle it programmatically and provide meaningful feedback to application users.

To Reproduce

  login: async ({ email, password, providerName }) => {
    try {
      const { data, error } = providerName
        ? await supabaseClient.auth.signInWithOAuth({
            provider: providerName,
          })
        : await supabaseClient.auth.signInWithPassword({
            email,
            password,
          });

      console.log({ data, error });

      if (error) throw error;

      if (data?.url || data?.user)
        return {
          success: true,
          redirectTo: "/dashboard",
        };
    } catch (error) {
      return {
        success: false,
        error: error,
      };
    }
  },

Expected behavior

The returned error prop should return the Error.

Screenshots

N/A

System information

Latest everything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auth-jsRelated to the auth-js library.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions