refresh_oauth_secret: take the secret from the clipboard when there is no terminal
Some checks are pending
crdt-sync pre-commit / pre-commit (push) Waiting to run
crdt-sync tests / test (push) Waiting to run
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run

Run through Claude Code's `!` there is no stdin to paste into, and the
console dialog's copy button has already put the value on the clipboard.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019pBgaXSJKyY3DarYpDatDF
This commit is contained in:
Krzysztof Rudnicki 2026-09-11 14:19:19 +02:00
parent e56aec431c
commit 94407268f0

View File

@ -49,10 +49,18 @@ main() {
echo " Client secret. If it says the secret was rotated, copy the NEW one."
xdg-open "$CONSOLE_URL" </dev/null >/dev/null 2>&1 || echo " (open manually: $CONSOLE_URL)"
echo "2. Paste it here and press Enter (not shown):"
local secret
# -s needs a terminal; piped input (tests) falls back to a plain read.
if [[ -t 0 ]]; then read -rs secret; echo; else read -r secret; fi
if [[ -t 0 ]]; then
echo "2. Paste it here and press Enter (not shown):"
read -rs secret; echo
else
# No terminal (run through Claude Code's `!`, or piped): the dialog's
# copy button already put the secret on the clipboard, so take it
# from there rather than asking for a paste nobody can type.
echo "2. Reading the secret from the clipboard (copied from the dialog)."
secret="$(xclip -o -selection clipboard 2>/dev/null || cat)"
secret="${secret//[$'\r\n ']/}"
fi
if [[ ! $secret =~ ^GOCSPX-[A-Za-z0-9_-]{28}$ ]]; then
echo "Error: that does not look like a Web client secret (GOCSPX-…, 35 chars)" >&2
exit 1