Skip to content
>_VibeUnstuck

Invalid login credentials

Last verified:

The fix

Invalid login credentials. Supabase Auth code invalid_credentials. The email and password did not match a password user. This is not Email not confirmed.

  1. 1

    Read the code on the error object

    error.code of invalid_credentials is this page. email_not_confirmed is the confirm-email page. Do not turn Confirm Email off because the password was rejected.

  2. 2

    Confirm this project has a password for that email

    In Authentication, Users, open the user. A provider of email means a password exists. An OAuth-only user cannot signInWithPassword until they set a password with a recovery link or you create the password user through the Auth API. Resetting the password in the dashboard sets a password on that user. Do not insert a row into auth.users with SQL to invent one. That leaves auth columns null and breaks later sign-ins.

  3. 3

    Match the project, then retry one sign-in

    The URL and the anon key in the client have to be this project. A user created in a branch or another project is not in this one. Ask for the email and password again. Do not log the password. Do not catch the error and store a fake session.

    const { data, error } = await supabase.auth.signInWithPassword({
      email,
      password,
    });
    if (error?.code === "invalid_credentials") {
      // wrong email, wrong password, or no password on this user
    }
  4. 4

    Leave the email provider on if password sign-in is the product

    Authentication, Providers, Email has to allow email signups and password sign-in if that is how the form works. email_provider_disabled is the code when it does not. A redirect to localhost after a successful OAuth login is the OAuth page, not a bad password.

Why it happens

Supabase's auth error list describes invalid_credentials as: login credentials or grant type not recognized. signInWithPassword returns Invalid login credentials when the email and password are not a match, when no password user has that email, or when the grant is not one this project accepts. The message is the same for an unknown email and a wrong password. That is deliberate.

email_not_confirmed is a different code and a different sentence. A right password on an unconfirmed user does not come back as invalid credentials. email_provider_disabled means email and password sign-in is turned off. An OAuth-only user has no password, so password sign-in returns invalid credentials until they set one. The anon key and the project URL still have to be the project where the user was created. A key from another project fails earlier, as Invalid API key.

The next error you'll probably hit

Once this is fixed, the usual follow-up is Email not confirmed. Supabase Auth refused sign-in because this user has not confirmed their email. The error code is email_not_confirmed.

Prompt to paste back into your AI tool

Paste this above the error.

Supabase Auth returns: Invalid login credentials. error.code is <code, or unknown>. The call is signInWithPassword. The project URL host is <host>.

Do not turn off Confirm Email. Do not insert into auth.users with SQL. Do not log or echo the password. Do not put the service role key in the client. Do not treat email_not_confirmed as this error.

1. If the code is email_not_confirmed, stop and follow that fix.
2. If the code is invalid_credentials, say whether this email has a password user in this project or only an OAuth identity.
3. If there is no password, send a recovery link or set a password in the dashboard. Do not write auth.users by hand.
4. If the code is email_provider_disabled, say the email provider is off. Change only the sign-in call's error handling if the message is being swallowed.

Common questions

+The password is correct and the error is still Invalid login credentials. What else is it?

The email has no password user in this project, the user was created in another project, or the grant is not password. Check the user in this project's Authentication list. Email not confirmed is a different code.

+Will Supabase tell the user the email is unknown?

No. invalid_credentials is the same sentence for an unknown email and a wrong password. Do not branch the UI on a difference the API does not return.

Related errors