PRACTICAL FIELD GUIDE
Login returns 401 invalid_credentials: causes and fixes
An invalid_credentials response identifies a failed login, not a reason to log the submitted password. Check the project and request mapping before changing the user's data.
MCPBackend editorial team · · Examples are illustrative
The short answer
MCPBackend returns 401 with code invalid_credentials from POST /v1/{projectId}/auth/login when no user with that email exists in this project or the password does not match. It deliberately uses the same error for both, so a login form cannot be used to discover which emails have accounts. The most common real cause is not a wrong password: it is a login request sent to a different project than the one the user signed up in.
Causes in order of likelihood
- Wrong project. App users belong to one project. A user who signed up against a staging project does not exist in production, even with the same email.
- Typo or stale password. Emails are compared in lower case, so capitalisation is not the problem; whitespace pasted into the password field can be.
- Body shape. The endpoint expects JSON with email and password fields. A malformed body returns 400 bad_request, not 401, so a 401 means the request itself was understood.
- The user was never created. A signup that failed silently (for example, the UI ignored a 400) leaves no account to log in to.
Errors that look similar but mean something else
- 403 auth_disabled: app-user authentication is not turned on for this project. Enable it in the dashboard or with the set_auth_enabled MCP tool.
- 403 account_disabled: the email and password matched, but the account is disabled.
- 404 not_found: the project ID in the URL is wrong.
- 401 unauthorized on a data request: the token is missing or was issued for a different project. That is a token problem, not a login problem.
Put it into practice
- Verify the app uses the intended project auth endpoint.
- Inspect field names and transport errors with secret values redacted.
- Test a known disposable account and show a generic useful failure message in the UI.
What this looks like
ILLUSTRATIVE EXAMPLE
The login form accidentally targets the staging project while the account was created in production. The same email does not imply a shared user store.
A boundary to keep clear
Never include raw passwords or bearer tokens in analytics, support screenshots or browser console logs.
Read next
MCPBackend context
Application email/password authentication is separate from the developer dashboard login and MCP OAuth connection. The current app-user tokens are project-scoped and do not automatically expire. Do not assume built-in refresh, password reset, per-token revocation or social login; check supported behavior before designing those flows.
Take the next step
Inspect the current project contract, try the change with disposable data, and verify the result through the same credentials your app will use. Record the expected response and one denied-access case before release.
Frequently asked questions
Why doesn't the API say whether the email or the password was wrong?
Returning one error for both stops attackers from checking which emails are registered. Show users a single message such as "Email or password is incorrect".
Is the email case-sensitive?
No. MCPBackend lower-cases the email at signup and at login, so Alice@Example.com and alice@example.com are the same account.
Can I reset the user's password from the API?
There is no built-in password reset flow today. Check what the product supports before promising one in your app.
Sources and further reading
These references explain the underlying protocols and design principles. For supported MCPBackend operations and exact request shapes, inspect your project’s generated API contract.