Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from bundle
Operational SendPulse skill with live-verified REST, MCP handshake, and MCP tool-call tests.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/rest_oauth_smoke.sh
1#!/usr/bin/env bash2set -euo pipefail34BASE_URL="https://api.sendpulse.com"5CLIENT_ID="${SENDPULSE_CLIENT_ID:-}"6CLIENT_SECRET="${SENDPULSE_CLIENT_SECRET:-}"7DRY_RUN=089usage() {10cat <<'EOF'11Usage:12rest_oauth_smoke.sh [--client-id <id>] [--client-secret <secret>] [--base-url <url>] [--dry-run]1314Purpose:15Obtain a SendPulse OAuth access token with client_credentials,16then run a safe GET /user/info smoke test.1718Env fallback:19SENDPULSE_CLIENT_ID20SENDPULSE_CLIENT_SECRET21EOF22}2324while [[ $# -gt 0 ]]; do25case "$1" in26--client-id)27CLIENT_ID="${2:-}"28shift 229;;30--client-secret)31CLIENT_SECRET="${2:-}"32shift 233;;34--base-url)35BASE_URL="${2:-}"36shift 237;;38--dry-run)39DRY_RUN=140shift41;;42-h|--help)43usage44exit 045;;46*)47echo "Unknown argument: $1" >&248usage >&249exit 150;;51esac52done5354if [[ -z "${CLIENT_ID}" || -z "${CLIENT_SECRET}" ]]; then55echo "Missing OAuth credentials. Pass --client-id/--client-secret or set SENDPULSE_CLIENT_ID and SENDPULSE_CLIENT_SECRET." >&256exit 157fi5859TOKEN_URL="${BASE_URL}/oauth/access_token"60INFO_URL="${BASE_URL}/user/info"61TOKEN_PAYLOAD=$(cat <<EOF62{"grant_type":"client_credentials","client_id":"${CLIENT_ID}","client_secret":"${CLIENT_SECRET}"}63EOF64)6566if [[ ${DRY_RUN} -eq 1 ]]; then67echo "[dry-run] POST ${TOKEN_URL}"68echo "[dry-run] payload: {\"grant_type\":\"client_credentials\",\"client_id\":\"<redacted>\",\"client_secret\":\"<redacted>\"}"69echo "[dry-run] then GET ${INFO_URL} with Authorization: Bearer <access_token>"70exit 071fi7273TOKEN_RESPONSE=$(curl --silent --show-error --fail-with-body \74-X POST "${TOKEN_URL}" \75-H 'Accept: application/json' \76-H 'Content-Type: application/json' \77--data "${TOKEN_PAYLOAD}")7879ACCESS_TOKEN=$(python3 - <<'PY' "${TOKEN_RESPONSE}"80import json, sys81payload = json.loads(sys.argv[1])82token = payload.get("access_token")83if not token:84raise SystemExit("No access_token in OAuth response")85print(token)86PY87)8889curl --silent --show-error --fail-with-body \90-H 'Accept: application/json' \91-H "Authorization: Bearer ${ACCESS_TOKEN}" \92"${INFO_URL}"93