Skip to content
Closed
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
25 changes: 18 additions & 7 deletions scripts/oauth-login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,29 @@ PYEOF
SERVER_PID=$!

# --- Open browser ---
if [[ "$(uname)" == "Darwin" ]]; then
open "$AUTH_URL" 2>/dev/null || true
elif command -v xdg-open >/dev/null 2>&1; then
xdg-open "$AUTH_URL" 2>/dev/null || true
fi

echo "Opening browser for Codeflash login..."
echo ""
echo "If the browser didn't open, visit this URL:"
echo "If the browser doesn't open, visit this URL manually:"
echo "$AUTH_URL"
echo ""

BROWSER_OPENED=false
if [[ "$(uname)" == "Darwin" ]]; then
if timeout 5 open "$AUTH_URL" 2>/dev/null; then
BROWSER_OPENED=true
fi
elif command -v xdg-open >/dev/null 2>&1; then
if timeout 5 xdg-open "$AUTH_URL" 2>/dev/null; then
BROWSER_OPENED=true
fi
fi

if [ "$BROWSER_OPENED" = false ]; then
echo "Could not open browser automatically (headless environment?)."
echo "Please open the URL above in your browser to complete login."
echo ""
fi

# --- Wait for callback ---
WAITED=0
while [ ! -s "$RESULT_FILE" ] && [ "$WAITED" -lt "$TIMEOUT" ]; do
Expand Down
Loading