{"record":{"id":"65ae64168b4c9e85","repo":"windmill-labs/windmill","slug":"unauthorized-could-not-authenticate-with-the-prov","errorCode":null,"errorMessage":"Unauthorized: Could not authenticate with the provided credentials","messagePattern":"Unauthorized: Could not authenticate with the provided credentials","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/core/auth.ts","lineNumber":130,"sourceCode":"            `Could not authenticate with the provided credentials. Please check your --token and --base-url and try again.${bodyStr ? `\\n${bodyStr}` : \"\"}`\n          ));\n        } else {\n          log.infoStderr(colors.red(\n            `Request failed (${status ?? \"unknown\"}): ${bodyStr}`\n          ));\n        }\n        return process.exit(1);\n      }\n      log.infoStderr(colors.red(\"Could not authenticate with the provided credentials. Please check your --token and --base-url and try again.\"));\n      return process.exit(1);\n    }\n\n    log.infoStderr(\n      \"! Could not reach API given existing credentials. Attempting to reauth...\"\n    );\n    const newToken = await loginInteractive(workspace.remote);\n    if (!newToken) {\n      throw new Error(\"Unauthorized: Could not authenticate with the provided credentials\");\n    }\n\n    // Update workspace token\n    const { removeWorkspace, addWorkspace } = await import(\"../commands/workspace/workspace.ts\");\n    removeWorkspace(workspace.name, false, opts);\n    workspace.token = newToken;\n    addWorkspace(workspace, opts);\n\n    setClient(\n      newToken,\n      workspace.remote.substring(0, workspace.remote.length - 1)\n    );\n    return await fetchWhoami(workspace.workspaceId);\n  }\n}\n","sourceCodeStart":112,"sourceCodeEnd":146,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/core/auth.ts#L112-L146","documentation":"requireLogin got an HTTP 401/403-class response from the whoami call: the token (--token, stored login, or workspace token) is invalid, expired, or scoped to the wrong instance, so authentication cannot proceed and the CLI exits.","triggerScenarios":"Thrown at cli/src/core/auth.ts:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the token in the Windmill UI and pass it via --token.","Re-run `wmill login` to refresh stored credentials.","Confirm --base-url points at the instance the token was issued for."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}