← Back to Skills Marketplace
igorivanter

Headless OAuth

by Igor Ivanter · GitHub ↗ · v1.3.1 · MIT-0
cross-platform ✓ Security Clean
130
Downloads
1
Stars
0
Active Installs
5
Versions
Install in OpenClaw
/install headless-oauth
Description
Authorize any OAuth CLI on a headless server where the agent and the user are on separate machines. Use when a CLI tool requires OAuth login on a VPS or serv...
README (SKILL.md)

Headless OAuth

Authorize CLI tools that require OAuth on a headless server — no browser needed on the server side.

⚠️ Agent Context: You Are on a Remote Server

You (the agent) are running on a remote VPS. The user is on a separate local machine with a browser.

This means:

  • You cannot open a browser yourself
  • The server's localhost is NOT accessible from the user's browser
  • The user must open all auth URLs on their own machine
  • When a redirect goes to a local address like http://127.0.0.1:PORT/callback?code=..., it will fail to load in the user's browser — that is expected and normal
  • The user should copy the full URL from the address bar (even if the page shows an error) and send it to you
  • You then forward that URL to the waiting server process via curl

Always make this explicit when asking the user to authorize. Example:

"Open this URL in your browser, log in, and approve. The page will likely fail to load — that's fine. Copy the full URL from the address bar and send it to me."


The Pattern

Split the browser flow across two machines:

SERVER                          LOCAL MACHINE
------                          -------------
1. Generate auth URL    →       2. Open URL in browser
                                3. Log in + grant permissions
                                4. Copy redirect URL or code
5. Exchange for token   ←
6. Store token locally

Most OAuth CLIs support this via flags like:

  • --no-launch-browser — gh (GitHub CLI), gcloud
  • --remote --step 1/2 — gog (Google Workspace CLI)
  • --manual — some generic CLIs
  • Device flow (code + URL, no redirect) — gh, some others

Keyring on Headless Servers

Many CLIs store tokens in a system keyring that requires an interactive terminal session to unlock. Check the CLI's documentation for a flag or environment variable that sets the keyring password non-interactively. Set it only for the duration of the auth step — do not persist it in shell configs or agent-global environment. Prefer injecting it from a secrets manager or an ephemeral shell session.


Google Workspace — gog CLI

gog supports headless auth via --remote --step 1/2. See the official gog docs for setup details.

Important: Use Desktop app OAuth client type in Google Cloud Console — not Web application. gog uses a random port for the callback, which Web clients reject with redirect_uri_mismatch.


GitHub CLI — gh

gh auth login --hostname github.com --git-protocol https --no-launch-browser
# → prints a one-time code and a URL
# Open https://github.com/login/device locally, enter the code
# gh polls and completes automatically once you approve

gcloud (Google Cloud CLI)

gcloud auth login --no-launch-browser
# → prints a URL
# Open in local browser, log in, copy the verification code shown, paste back

Generic Device Flow

If a CLI supports device flow (prints a short code + URL):

  1. Note the code and URL printed by the CLI
  2. Open the URL on any device
  3. Enter the code
  4. CLI polls and completes automatically — no redirect URL to copy

Manual Callback Relay (mcporter, custom OAuth servers)

Some tools (e.g. mcporter) start a local HTTP server on the server to catch the OAuth callback, but the user's browser can't reach that address on the remote server.

How to handle it:

  1. Start the auth command with a longer timeout so it doesn't expire while waiting for the user. Check the tool's docs for a timeout flag or environment variable.
  2. The tool usually prints a message like:
    If the browser did not open, visit https://... manually.
    
    Send that URL to the user.
  3. Tell the user:

    "Open this URL, log in and approve. The page will fail to load — that's normal. Copy the full URL from the address bar and send it to me."

  4. The user sends back something like: http://127.0.0.1:PORT/callback?code=...&state=...
  5. Forward it to the waiting server with curl:
    curl -s "http://127.0.0.1:PORT/callback?code=...&state=..."
    
  6. The tool receives the code, exchanges it for a token, and completes authorization.

Troubleshooting

Error Fix
redirect_uri_mismatch Use Desktop app OAuth client, not Web application
No TTY / keyring unlock fails Check the CLI's docs for a non-interactive keyring option
Access blocked (testing mode) Add your email as test user in Google consent screen settings
Commands fail silently Check if the CLI requires an account env var to be set
Token expired Re-run auth steps; most CLIs handle refresh automatically

Applying This Pattern to Any CLI

  1. Check --help for flags like --no-launch-browser, --remote, --manual, or --headless
  2. Check docs for "device flow" or "offline access"
  3. If the tool starts a local callback server but has no headless flag — use the Manual Callback Relay pattern above
  4. If none of the above work: use ssh -L port forwarding to tunnel the callback to your local machine
Usage Guidance
This skill is a focused recipe for completing OAuth when the server is headless and the user has the browser. It legitimately asks the user to paste redirect URLs or device codes (these are sensitive authorization values). Before installing or using it: (1) Confirm you trust the agent/host — the agent will see short-lived auth codes and may store tokens on the server. (2) Prefer device flow where possible (no redirect URLs to copy). (3) Ensure the agent only forwards the copied URL to the server's localhost as described and not to any external endpoint. (4) Avoid persisting keyring passwords or tokens in shell startup files; use ephemeral secrets or a secrets manager for the auth step. The skill itself contains no hidden installs or unrelated credential requests and appears coherent with its stated purpose.
Capability Analysis
Type: OpenClaw Skill Name: headless-oauth Version: 1.3.1 The skill provides legitimate instructions and patterns for performing OAuth authentication on headless servers for common CLI tools like GitHub (gh) and Google Cloud (gcloud). It includes a 'Manual Callback Relay' pattern using curl to localhost, which is a standard technique for handling redirects when a browser cannot reach the remote server's local network, and it contains no evidence of data exfiltration or malicious intent (SKILL.md, README.md).
Capability Tags
requires-oauth-token
Capability Assessment
Purpose & Capability
The name/description match the SKILL.md content. All required actions (asking the user to open URLs, copying redirect URLs or device codes, relaying callbacks to localhost, and advising about keyrings) are directly relevant to headless OAuth and no unrelated credentials, binaries, or services are requested.
Instruction Scope
The instructions explicitly require the user to paste full redirect URLs or codes (which contain sensitive authorization codes) and tell the agent to forward those to the server via curl to localhost. This is expected for the workflow, but it means the agent will handle sensitive tokens/codes during the flow — users should be aware these values are secret and transient. The skill does not instruct the agent to read unrelated files or exfiltrate data to external hosts.
Install Mechanism
Instruction-only skill with no install spec and no code files. Nothing is written to disk or fetched at install time, which minimizes installation risk.
Credentials
The skill requests no environment variables or credentials, which is proportional. It does advise storing tokens locally (as any OAuth flow does) and warns about keyring unlocking. Users should avoid persisting secrets in shell configs and prefer ephemeral injection from a secrets manager.
Persistence & Privilege
The skill does not request permanent presence (always:false) and does not modify other skills or system-wide settings. Autonomous invocation is allowed by platform default but not by this skill's configuration alone.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install headless-oauth
  3. After installation, invoke the skill by name or use /headless-oauth
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.3.1
Fix README: remove stale env var examples and bashrc persistence suggestion.
v1.3.0
Remove all specific env var names and binary install instructions. Add Manual Callback Relay pattern for mcporter/MCP servers. Add explicit agent context guidance (remote server / local browser split). Update description to reflect all three OAuth patterns.
v1.0.2
Remove recommendation to persist keyring passwords in shell/agent config. Add explicit security guidance throughout.
v1.0.1
Remove personal data from examples, improve security guidance around keyring passwords, fix README badge.
v1.0.0
Initial release: authorize any OAuth CLI on a headless server.
Metadata
Slug headless-oauth
Version 1.3.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 5
Frequently Asked Questions

What is Headless OAuth?

Authorize any OAuth CLI on a headless server where the agent and the user are on separate machines. Use when a CLI tool requires OAuth login on a VPS or serv... It is an AI Agent Skill for Claude Code / OpenClaw, with 130 downloads so far.

How do I install Headless OAuth?

Run "/install headless-oauth" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Headless OAuth free?

Yes, Headless OAuth is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Headless OAuth support?

Headless OAuth is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Headless OAuth?

It is built and maintained by Igor Ivanter (@igorivanter); the current version is v1.3.1.

💬 Comments