fix: use python3 to parse OAuth2 token response (handles spaces in JSON)
This commit is contained in:
@@ -51,10 +51,9 @@ jobs:
|
||||
-d "client_secret=${{ secrets.CWS_CLIENT_SECRET }}" \
|
||||
-d "refresh_token=${{ secrets.CWS_REFRESH_TOKEN }}" \
|
||||
-d "grant_type=refresh_token")
|
||||
echo "TOKEN_RESPONSE: $(echo $TOKEN_RESPONSE | sed 's/"access_token":"[^"]*"/"access_token":"***"/g')"
|
||||
ACCESS_TOKEN=$(echo $TOKEN_RESPONSE | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
|
||||
ACCESS_TOKEN=$(echo "$TOKEN_RESPONSE" | python3 -c "import json,sys; d=json.load(sys.stdin); print(d['access_token'])" 2>/dev/null)
|
||||
if [ -z "$ACCESS_TOKEN" ]; then
|
||||
echo "❌ Failed to get access token"
|
||||
echo "❌ Failed to get access token. Response: $TOKEN_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
echo "CWS_ACCESS_TOKEN=${ACCESS_TOKEN}" >> $GITHUB_ENV
|
||||
|
||||
Reference in New Issue
Block a user