You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: Plugin client returns 401 Unauthorized when OPENCODE_SERVER_PASSWORD is set (Desktop) #8676
When running OpenCode via Desktop app, plugins that use client.session.create(), client.session.prompt(), or other HTTP API calls receive 401 Unauthorized errors.
Root Cause
OpenCode Desktop (Tauri) automatically generates a UUID password and sets OPENCODE_SERVER_PASSWORD environment variable when spawning the local server:
packages/desktop/src-tauri/src/lib.rs:416
let password = uuid::Uuid::new_v4().to_string();
packages/desktop/src-tauri/src/lib.rs:159
.env("OPENCODE_SERVER_PASSWORD", password)
This enables the basicAuth middleware in server.ts:
However, the client created for plugins in plugin/index.ts does not include the corresponding Basic Auth credentials, causing all plugin HTTP requests to fail with 401.
Steps to Reproduce
Install OpenCode Desktop (exe version)
Install a plugin that uses client.session.create() (e.g., @menkan/opencode with sisyphus_task)
Run the plugin tool
Observe 401 Unauthorized error
Proposed Fix
Add Basic Auth headers to the plugin client when OPENCODE_SERVER_PASSWORD is configured:
I actually also cannot connect to web from TUI if I have the password env variable set in my shell, but not even Desktop. CLI installed on macOS from curl. Version 1.1.21
This issue is being adressed and fixed by the pr #9095
The TUI would fail to send an auth header when it was started alongside a http server. In case a password or non default username is set via env vars, this leads to the 401 - not Authorized error.
Activity
github-actions commentedon Jan 15, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
hubertlepicki commentedon Jan 15, 2026
I actually also cannot connect to web from TUI if I have the password env variable set in my shell, but not even Desktop. CLI installed on macOS from curl. Version 1.1.21
LeonMueller-OneAndOnly commentedon Jan 17, 2026
This issue is being adressed and fixed by the pr #9095
The TUI would fail to send an auth header when it was started alongside a http server. In case a password or non default username is set via env vars, this leads to the 401 - not Authorized error.
gerchicov-vg commentedon Feb 19, 2026
it is not fixed. Changed key in account but it still returns the same error
david-christ commentedon Mar 1, 2026
As a temporary workaround when using the SDK, e.g. to write plugins, you can do this (messing with "private" methods):
github-actions commentedon May 1, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.