fix: rclone OAuth2 token JSON — use Node.js instead of shell echo to avoid escaping issues [skip ci]

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/5987057e-c76e-4db1-b9a5-849a9c70cb4e
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 11:29:45 +00:00
parent 882da48be2
commit 6f8399fed2
1 changed files with 20 additions and 9 deletions

View File

@ -49,16 +49,27 @@ jobs:
echo "✅ OAuth2 credentials validated"
# Use node to generate token JSON — avoids shell escaping issues with special characters
TOKEN_JSON=$(node -e "
const token = {
access_token: '',
token_type: 'Bearer',
refresh_token: process.env.GDRIVE_REFRESH_TOKEN,
expiry: '2000-01-01T00:00:00Z'
};
process.stdout.write(JSON.stringify(token));
")
mkdir -p "${HOME}/.config/rclone"
{
echo "[gdrive]"
echo "type = drive"
echo "scope = drive"
echo "client_id = ${GDRIVE_CLIENT_ID}"
echo "client_secret = ${GDRIVE_CLIENT_SECRET}"
echo "token = {\"access_token\":\"\",\"token_type\":\"Bearer\",\"refresh_token\":\"${GDRIVE_REFRESH_TOKEN}\",\"expiry\":\"2000-01-01T00:00:00Z\"}"
echo "root_folder_id = 1fqWdLPaZkUZYt4OT_h3fJQHnd-q5QN3G"
} > "${HOME}/.config/rclone/rclone.conf"
cat > "${HOME}/.config/rclone/rclone.conf" <<RCLONE_EOF
[gdrive]
type = drive
scope = drive
client_id = ${GDRIVE_CLIENT_ID}
client_secret = ${GDRIVE_CLIENT_SECRET}
token = ${TOKEN_JSON}
root_folder_id = 1fqWdLPaZkUZYt4OT_h3fJQHnd-q5QN3G
RCLONE_EOF
chmod 600 "${HOME}/.config/rclone/rclone.conf"
echo "✅ rclone configured with OAuth2"