Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions skills/setup/scripts/github-device-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ trap cleanup_on_failure EXIT
# oauth_pkce_verifier cookies. We don't follow the redirect;
# we just need the cookies and the state value from the
# Location header.
echo "Saving GitHub OAuth cookies to $JAR" >&2
LOC="$(curl -sS -D - -o /dev/null \
--cookie-jar "$JAR" --max-redirs 0 \
"$ACCESS_URL/api/v2/users/oauth2/github/callback" |
Expand All @@ -60,6 +61,7 @@ DEV_JSON="$(curl -sSf "$ACCESS_URL/api/v2/users/oauth2/github/device")"
# 1c. Write the values to a state file the agent and step 3 will
# read. Plain shell-source format so the polling step can
# `. "$STATE_DIR/github-device.env"`.
echo "Writing GitHub device-code parameters to $DEV_FILE" >&2
python3 - "$DEV_JSON" "$STATE" <<'PY' >"$DEV_FILE"
import json, sys, shlex
d = json.loads(sys.argv[1])
Expand Down
3 changes: 3 additions & 0 deletions skills/setup/scripts/github-device-poll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ trap cleanup_scratch EXIT
# {"redirect_url": "..."} and a Set-Cookie:
# coder_session_token=... header that's the admin's session.
DEADLINE=$(($(date +%s) + EXPIRES_IN))
echo "Polling Coder for sign-in completion; responses captured to $RESP" >&2
while :; do
HTTP=$(curl -sS -o "$RESP" -w '%{http_code}' \
--cookie "$JAR" --cookie-jar "$JAR" \
Expand Down Expand Up @@ -92,7 +93,9 @@ TOKEN="$(awk '$6 == "coder_session_token" { print $7 }' "$JAR" | tail -1)"
CFG="${CODER_CONFIG_DIR:-$HOME/.config/coderv2}"
mkdir -p "$CFG"
umask 0077
echo "Writing Coder server URL to $CFG/url" >&2
printf '%s' "$ACCESS_URL" >"$CFG/url"
echo "Writing Coder admin session token to $CFG/session" >&2
printf '%s' "$TOKEN" >"$CFG/session"

# Verify the CLI is signed in as the admin. (Scratch files are
Expand Down