sindresorhus/got · error · Error
Parameter `auth` is deprecated. Use `username` / `password`
Error message
Parameter `auth` is deprecated. Use `username` / `password` instead.
What it means
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`.
Source
Thrown at source/core/options.ts:3338
this.#internals.responseType = value;
}
get pagination(): PaginationOptions<unknown, unknown> {
return this.#internals.pagination;
}
set pagination(value: PaginationOptions<unknown, unknown>) {
assert.object(value);
if (this.#merging) {
safeObjectAssign(this.#internals.pagination, value);
} else {
this.#internals.pagination = value;
}
}
get auth() {
throw new Error('Parameter `auth` is deprecated. Use `username` / `password` instead.');
}
set auth(_value: unknown) {
throw new Error('Parameter `auth` is deprecated. Use `username` / `password` instead.');
}
get setHost() {
return this.#internals.setHost;
}
set setHost(value: boolean) {
assert.boolean(value);
this.#internals.setHost = value;
}
get maxHeaderSize() {
return this.#internals.maxHeaderSize;View on GitHub (pinned to e3924aa1e5)
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).
Example fix
// before
options.auth = 'user:pass';
const auth = options.auth;
// after
options.username = 'user';
options.password = 'pass';
const {username, password} = options; Defensive patterns
Strategy: validation
Validate before calling
// Before reading, check the own-property without invoking the getter:
if (Object.hasOwn(options, 'username')) {
// use options.username / options.password
} else {
// no legacy auth to read
} Type guard
// No type guard can read .auth (the getter throws).
// Narrow on the replacement fields instead:
const hasCredentials = (o: unknown): o is {username?: string; password?: string} =>
typeof o === 'object' && o !== null &&
('username' in o || 'password' in o); Prevention
- 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.
When it happens
Trigger: 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)`.
Common situations: 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`.
Related errors
- The `searchParameters` option does not exist. Use `searchPar
- The `followRedirects` option does not exist. Use `followRedi
- To get a Uint8Array, set `options.responseType` to `buffer`
- The defaults must be passed as the third argument
- The `url` option is mutually exclusive with the `input` argu
AI-assisted analysis of sindresorhus/got@e3924aa1e5 (2026-08-03).
Data as JSON: /data/errors/96df3e6f15e78419.json.
Report an issue: GitHub.