Skip to content

chore(scripts): add Windows PowerShell OAuth token exporter#42

Merged
szjanikowski merged 2 commits into
mainfrom
windows/oauth-token-script
May 9, 2026
Merged

chore(scripts): add Windows PowerShell OAuth token exporter#42
szjanikowski merged 2 commits into
mainfrom
windows/oauth-token-script

Conversation

@szjanikowski
Copy link
Copy Markdown
Contributor

Summary

  • Adds scripts/export_oauth_token.ps1, the Windows-side counterpart of scripts/export_oauth_token.sh.
  • Reads %USERPROFILE%\.claude\.credentials.json (where the claude CLI stores credentials on Windows — no Keychain) and exports $env:CLAUDE_CODE_OAUTH_TOKEN in the current PowerShell session.
  • Use via dot-source: . .\scripts\export_oauth_token.ps1

Why

Existing export_oauth_token.sh calls security find-generic-password, which only exists on macOS. Windows users had to extract the token manually before running nasde run.

Verification

End-to-end check on Windows 11 + Docker Desktop:

  • Dot-sourcing the script sets $env:CLAUDE_CODE_OAUTH_TOKEN (108-char token).
  • docker run --rm -e CLAUDE_CODE_OAUTH_TOKEN ubuntu:22.04 ... reproduces the same length inside the container.
  • Harbor's ClaudeCode.run() reads the var via os.environ.get("CLAUDE_CODE_OAUTH_TOKEN", "") (harbor/agents/installed/claude_code.py:979) and forwards it to environment.exec(env=...), so nasde run inherits it transparently.

Test plan

  • On Windows: . .\scripts\export_oauth_token.ps1 prints OK CLAUDE_CODE_OAUTH_TOKEN exported (sk-ant-oat01-...).
  • $env:CLAUDE_CODE_OAUTH_TOKEN.Length reports the current token length.
  • nasde run --variant claude-vanilla -C examples/... from the same PowerShell session uses the subscription token (no ANTHROPIC_API_KEY needed).

🤖 Generated with Claude Code

scripts/export_oauth_token.ps1 mirrors export_oauth_token.sh for
Windows: reads %USERPROFILE%\.claude\.credentials.json (where the
`claude` CLI stores credentials on Windows — there's no Keychain) and
exports $env:CLAUDE_CODE_OAUTH_TOKEN for the current PowerShell
session. Use via dot-source:

    . .\scripts\export_oauth_token.ps1

Verified end-to-end: the env var set by this script flows through
`nasde run` into Harbor's ClaudeCode agent
(harbor/agents/installed/claude_code.py:979) and is forwarded into
the sandbox container.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@szjanikowski szjanikowski marked this pull request as draft May 8, 2026 09:24
- export_oauth_token.sh: fall back to ~/.claude/.credentials.json on Linux
  (no Keychain). macOS path unchanged. Validates that fallback may need
  adjustment if `claude` CLI on Linux uses libsecret instead of plain JSON
  — flagged for VM testing.
- Add export_codex_oauth_token.ps1 and export_gemini_oauth_token.ps1
  (Windows equivalents of the existing .sh scripts).
- Rewrite "Authentication setup" in nasde-benchmark-runner SKILL.md as
  per-agent / per-OS tables (macOS, Linux, Windows PS, Windows WSL).
  Skill now asks the user OAuth-vs-API-key per agent before running.
  cmd.exe documented as "use PowerShell or WSL".

Tested on macOS so far. Ubuntu VM and Windows 11 VM (PowerShell + WSL2)
validation pending.
@szjanikowski szjanikowski marked this pull request as ready for review May 9, 2026 09:47
@szjanikowski szjanikowski merged commit 091437e into main May 9, 2026
6 checks passed
szjanikowski added a commit that referenced this pull request May 9, 2026
* docs(changelog): record Windows compat + skill bundling under [Unreleased]

Captures everything that landed since v0.3.2 (PRs #42, #43, #44, #45) so
the release notes are queued up. Keeps the section under [Unreleased]
deliberately — more fixes are still expected before cutting v0.3.3, and
release docs say the version header should be added at release-cut time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(changelog): record .gitattributes LF enforcement (#47)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(changelog): record harbor[cloud] dependency switch (#48)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: release v0.3.3

Cuts v0.3.3 from the accumulated [Unreleased] section. Patch bump
(pre-1.0 policy): no breaking changes to user-facing CLI, nasde.toml
schema, or benchmark project layout — Windows compat, OAuth-script
bundling, harbor[cloud] dep switch are all transparent to users.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Szymon Janikowski <szymon.janikowski@itlibrium.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@szjanikowski szjanikowski deleted the windows/oauth-token-script branch May 9, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant