{"record":{"id":"a7e913c6c3fcccb0","repo":"yarnpkg/yarn","slug":"incorrectcredentials","errorCode":null,"errorMessage":"incorrectCredentials","messagePattern":"incorrectCredentials","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/login.js","lineNumber":127,"sourceCode":"    body: userobj,\n    auth: {username, password, email},\n  });\n\n  if (res && res.ok) {\n    reporter.success(reporter.lang('loggedIn'));\n\n    const token = res.token;\n    config.registries.npm.setToken(`Bearer ${token}`);\n\n    return async function revoke(): Promise<void> {\n      reporter.success(reporter.lang('revokedToken'));\n      await config.registries.npm.request(`-/user/token/${token}`, {\n        method: 'DELETE',\n        registry,\n      });\n    };\n  } else {\n    throw new MessageError(reporter.lang('incorrectCredentials'));\n  }\n}\n\nexport function hasWrapper(commander: Object, args: Array<string>): boolean {\n  return true;\n}\n\nexport function setFlags(commander: Object) {\n  commander.description('Stores registry username and email.');\n}\n\nexport async function run(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {\n  await getCredentials(config, reporter);\n}\n","sourceCodeStart":109,"sourceCodeEnd":142,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/login.js#L109-L142","documentation":"In the interactive login flow, after submitting username/password the code expects a token back (login.js ~token assignment). Reaching the `throw ... 'incorrectCredentials'` branch means the registry did not return a token for the supplied credentials, i.e. authentication failed.","triggerScenarios":"Typo in username or password; expired/locked account; password manager autofill error; account requiring 2FA where the flow did not complete; registry returning an empty/missing token object.","commonSituations":"Caps-lock / wrong keyboard layout; stale saved credentials; account disabled after failed attempts; corporate npm registry with SSO that needs a different login path.","solutions":["Re-run `yarn login` and re-enter username and password carefully.","Verify the account at the registry web UI (npmjs.com) and reset password if needed.","Disable autofill / re-type credentials manually to rule out stale values.","If 2FA/SSO is required, follow the registry-specific flow or use a personal access token via NPM_AUTH_TOKEN instead."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await runYarn(['login']);\n} catch (e) {\n  if (/incorrectCredentials/.test(e.message)) {\n    console.error('Login failed: check username/password, 2FA, or use a personal access token.');\n    return;\n  }\n  throw e;\n}","preventionTips":["Use a personal access token via NPM_AUTH_TOKEN instead of interactive passwords in automation.","Verify account status and 2FA setup at the registry before scripting logins.","Avoid password autofill for one-off logins; type credentials manually."],"tags":["cli","auth","credentials","login"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}