opencode-anthropic-login-via-cli-remote
v1.4.0
Published
Fork of opencode-anthropic-login-via-cli with a workaround for copying the OAuth URL in remote and containerized environments.
Downloads
128
Maintainers
Readme
Fork Notes
This is a fork of opencode-anthropic-login-via-cli with a workaround for copying the OAuth URL in remote and containerized environments.
The Problem
When authenticating via Claude Pro/Max (browser), the OAuth URL is too long to fit on one line in the OpenCode TUI dialog. The TUI intercepts mouse and keyboard events, making it impossible to cleanly select and copy the URL. This affects anyone without direct desktop access to the machine running OpenCode.
What This Fork Adds
When the env var OAUTH_URL_DIR is set, the plugin writes the full OAuth URL to $OAUTH_URL_DIR/oauth-url.txt as a single line each time the browser auth dialog opens. You can then read it from a second terminal and copy it cleanly into your browser.
If OAUTH_URL_DIR is not set, the plugin behaves exactly as the original — nothing is written and no message is shown.
Usage
Docker
Define the host and container paths once, then reference them in the docker command:
export OAUTH_URL_HOST_DIR=~/.opencode-auth
export OAUTH_URL_DIR=/root/.opencode-auth
docker run -it --rm \
-v /path/to/opencode-config/:/root/.config/opencode \
-v "$PWD":/workspace \
-e OAUTH_URL_DIR="${OAUTH_URL_DIR}" \
-v "${OAUTH_URL_HOST_DIR}":"${OAUTH_URL_DIR}" \
-w /workspace \
ghcr.io/anomalyco/opencodeWhen the auth dialog appears, on your host:
cat ~/.opencode-auth/oauth-url.txtRemote environment (SSH, devcontainers, etc.)
Set the env var to any writable directory on the remote machine before starting OpenCode:
export OAUTH_URL_DIR=~/.opencode-auth
opencodeWhen the auth dialog appears, in a second session to the same machine:
cat ~/.opencode-auth/oauth-url.txtOpenCode Anthropic Auth
OpenCode plugin that lets you use Anthropic models with your Claude Pro/Max subscription. No API key required.
Features
Binary Introspection
Reads the Claude CLI binary to extract current beta headers, OAuth scopes, and version info. Stays in sync with Anthropic's API automatically instead of relying on hardcoded values.
Cross-Platform Support
Works on macOS, Linux, and Windows.
Auto Login
If you have Claude CLI installed and logged in, the plugin picks up your credentials automatically:
- macOS: System Keychain
- Linux / Windows:
~/.claude/.credentials.json
CCS Support
If you use CCS for multiple Claude Code instances, each instance in ~/.ccs/instances/ is detected and shows up as a separate auth method.
Browser Login
Opens an OAuth flow through claude.com for users without the CLI. Log in, paste the code, done.
Token Refresh
Handles expired tokens automatically. Falls back to the CLI if the standard refresh fails.
Request Patching
Patches requests so OpenCode talks to Anthropic's API the same way Claude Code does.
Install
Add to your opencode.json:
{
"plugin": ["opencode-anthropic-login-via-cli-remote@latest"]
}Then open OpenCode and go to Connect Provider > Anthropic.
Auth Methods
| Method | Label | How it works |
| ------- | ------------------------ | ------------------------------------------------------- |
| Auto | Claude Code (auto) | Reads existing CLI credentials from Keychain/filesystem |
| CCS | CCS (instance-name) | Auto-detects each CCS instance in ~/.ccs/instances/ |
| Browser | Claude Pro/Max (browser) | OAuth flow via claude.com with PKCE |
| API Key | API Key (manual) | Standard Anthropic API key |
License
MIT
