{"id":"96df3e6f15e78419","repo":"sindresorhus/got","slug":"parameter-auth-is-deprecated-use-username","errorCode":null,"errorMessage":"Parameter `auth` is deprecated. Use `username` / `password` instead.","messagePattern":"Parameter `auth` is deprecated\\. Use `username` / `password` instead\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/core/options.ts","lineNumber":3338,"sourceCode":"\t\tthis.#internals.responseType = value;\n\t}\n\n\tget pagination(): PaginationOptions<unknown, unknown> {\n\t\treturn this.#internals.pagination;\n\t}\n\n\tset pagination(value: PaginationOptions<unknown, unknown>) {\n\t\tassert.object(value);\n\n\t\tif (this.#merging) {\n\t\t\tsafeObjectAssign(this.#internals.pagination, value);\n\t\t} else {\n\t\t\tthis.#internals.pagination = value;\n\t\t}\n\t}\n\n\tget auth() {\n\t\tthrow new Error('Parameter `auth` is deprecated. Use `username` / `password` instead.');\n\t}\n\n\tset auth(_value: unknown) {\n\t\tthrow new Error('Parameter `auth` is deprecated. Use `username` / `password` instead.');\n\t}\n\n\tget setHost() {\n\t\treturn this.#internals.setHost;\n\t}\n\n\tset setHost(value: boolean) {\n\t\tassert.boolean(value);\n\n\t\tthis.#internals.setHost = value;\n\t}\n\n\tget maxHeaderSize() {\n\t\treturn this.#internals.maxHeaderSize;","sourceCodeStart":3320,"sourceCodeEnd":3356,"githubUrl":"https://github.com/sindresorhus/got/blob/e3924aa1e53a6ca3eb93a43618ce532442a89b40/source/core/options.ts#L3320-L3356","documentation":"The `auth` getter is a hard-deprecated accessor on the Options class: reading `options.auth` always throws because the property no longer exists. The library migrated Basic-auth credentials to dedicated `username` and `password` options (which are encoded into the Authorization header internally). The getter exists only to surface a loud, migration-steering error rather than silently returning `undefined`.","triggerScenarios":"Any code path that reads `got(...).auth`, `defaults.options.auth`, or destructures `{auth}` from a Got Options instance throws immediately. Common triggers: logging `options`, serializing to JSON via a custom inspector that walks getters, or legacy code that branches on `if (options.auth)`.","commonSituations":"Upgrading from Got 11 (where `auth` was a `user:pass` string) to Got 12+; copy-pasted examples from old tutorials; debugging tools (console.log, util.inspect with getters:true) that enumerate accessors; shared option objects built by a helper that still sets `.auth`.","solutions":["Replace any read of `options.auth` with `options.username` / `options.password`.","Remove `.auth` from option-builder helpers and pass `{username, password}` instead.","If an inspector/logger trips the getter, exclude `auth` from serialization or guard reads with `'auth' in options` (own-property check that does not invoke the getter).","Search the codebase for `\\.auth\\b` and migrate every hit; the setter throws too (see error 41)."],"exampleFix":"// before\noptions.auth = 'user:pass';\nconst auth = options.auth;\n\n// after\noptions.username = 'user';\noptions.password = 'pass';\nconst {username, password} = options;","handlingStrategy":"validation","validationCode":"// Before reading, check the own-property without invoking the getter:\nif (Object.hasOwn(options, 'username')) {\n  // use options.username / options.password\n} else {\n  // no legacy auth to read\n}","typeGuard":"// No type guard can read .auth (the getter throws).\n// Narrow on the replacement fields instead:\nconst hasCredentials = (o: unknown): o is {username?: string; password?: string} =>\n  typeof o === 'object' && o !== null &&\n  ('username' in o || 'password' in o);","tryCatchPattern":null,"preventionTips":["Codemod the codebase to remove all `.auth` reads before upgrading Got.","Pin Got major version until the migration is complete.","Add an ESLint ban rule on the `auth` property name for Got option objects.","Use TypeScript with the library's exported option types so deprecated fields surface at compile time."],"tags":["deprecation","auth","migration","options"],"analyzedSha":"e3924aa1e53a6ca3eb93a43618ce532442a89b40","analyzedAt":"2026-08-03T19:22:24.770Z","schemaVersion":2}