OpenCode plugins cannot use client when the server has a password #8911

Closed
opened 2026-02-16 18:11:09 -05:00 by yindo · 2 comments
Owner

Originally created by @jacksonzamorano on GitHub (Feb 9, 2026).

Originally assigned to: @thdxr on GitHub.

Description

When using client in a OpenCode plugin, I get an "Unauthorized" error. I start the server with OPENCODE_SERVER_PASSWORD=x opencode serve --hostname 0.0.0.0. Because my plugin's client.app.log wasn't working, I fell back to console.log (which I see in the server logs). Using methods on client like session.get or app.log cause the authorized error: Session data: {"error":"Unauthorized","request":{},"response":{}}.

Plugins

A simple debugging script that logs on session.idle

OpenCode version

1.1.53

Steps to reproduce

  1. Make & install a basic plugin that calls any client method (for example, client.session.get) on a session.created event.
  2. Start a server with a password.
  3. Attach to it with a client.
  4. Within that client, trigger the event.
  5. Whatever client method you called will return unauthorized.

Screenshot and/or share link

Image

Operating System

macOS 26.2

Terminal

Ghostty

Originally created by @jacksonzamorano on GitHub (Feb 9, 2026). Originally assigned to: @thdxr on GitHub. ### Description When using `client` in a OpenCode plugin, I get an "Unauthorized" error. I start the server with `OPENCODE_SERVER_PASSWORD=x opencode serve --hostname 0.0.0.0`. Because my plugin's client.app.log wasn't working, I fell back to `console.log` (which I see in the server logs). Using methods on client like `session.get` or `app.log` cause the authorized error: `Session data: {"error":"Unauthorized","request":{},"response":{}}`. ### Plugins A simple debugging script that logs on session.idle ### OpenCode version 1.1.53 ### Steps to reproduce 1. Make & install a basic plugin that calls any client method (for example, client.session.get) on a session.created event. 2. Start a server with a password. 3. Attach to it with a client. 4. Within that client, trigger the event. 5. Whatever client method you called will return unauthorized. ### Screenshot and/or share link <img width="746" height="301" alt="Image" src="https://github.com/user-attachments/assets/71ea1c56-27b7-42e1-8e04-783237e36299" /> ### Operating System macOS 26.2 ### Terminal Ghostty
yindo added the bug label 2026-02-16 18:11:09 -05:00
yindo closed this issue 2026-02-16 18:11:09 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 9, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8676: Plugin client returns 401 Unauthorized when OPENCODE_SERVER_PASSWORD is set (Desktop) - same root cause and exact problem
  • #9706: Plugin client missing Authorization header when OPENCODE_SERVER_PASSWORD is set - identical issue with detailed analysis
  • #10182: Desktop: Background exploration agent fails with "Unauthorized" error - related auth issue in Desktop
  • #10369: background_task and look_at is error in desktop of windows - same Desktop/password auth issue
  • #9066: Failing to authenticate into web UI when username or password is set - related authentication problems

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 9, 2026): This issue might be a duplicate of existing issues. Please check: - #8676: Plugin client returns 401 Unauthorized when OPENCODE_SERVER_PASSWORD is set (Desktop) - same root cause and exact problem - #9706: Plugin client missing Authorization header when OPENCODE_SERVER_PASSWORD is set - identical issue with detailed analysis - #10182: Desktop: Background exploration agent fails with "Unauthorized" error - related auth issue in Desktop - #10369: background_task and look_at is error in desktop of windows - same Desktop/password auth issue - #9066: Failing to authenticate into web UI when username or password is set - related authentication problems Feel free to ignore if none of these address your specific case.
Author
Owner

@jacksonzamorano commented on GitHub (Feb 9, 2026):

This is a duplicate. Good job github actions bot.

@jacksonzamorano commented on GitHub (Feb 9, 2026): This is a duplicate. Good job github actions bot.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8911