Last active
June 18, 2026 17:54
-
-
Save TiloGit/d08b36ec5d08e148e2024ab989895b69 to your computer and use it in GitHub Desktop.
cmod rest api test CMODSharedKeyV2 and CMODSharedKey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| CMOD_HOST="http://vfcmod105.mydom.com:9085" | |
| ACCESS_KEY="odrestapi1-R____2A" | |
| SECRET_KEY="iH_____pQS" | |
| # ── CMODSharedKey (V1 - includes server URL) ────────────── | |
| cmod_curl_v1() { | |
| local METHOD="$1" URI="$2" BODY="${3:-}" | |
| local DATE=$(date -u "+%Y-%m-%dT%H:%M:%SZ") | |
| local STS=$(printf '%s\n%s\n%s\n%s\n%s' \ | |
| "$METHOD" "$DATE" "$CMOD_HOST" "$URI" "$ACCESS_KEY") | |
| local SIG=$(printf '%s' "$STS" \ | |
| | openssl dgst -sha256 -hmac "$SECRET_KEY" -binary | openssl base64) | |
| curl -s -X "$METHOD" "${CMOD_HOST}${URI}" \ | |
| -H "usi-date: $DATE" \ | |
| -H "Authorization: CMODSharedKey ${ACCESS_KEY}:${SIG}" \ | |
| ${BODY:+-H "Content-Type: application/json" -d "$BODY"} | |
| } | |
| # ── CMODSharedKeyV2 (no server URL) ────────────────────── | |
| cmod_curl_v2() { | |
| local METHOD="$1" URI="$2" BODY="${3:-}" | |
| local DATE=$(date -u "+%Y-%m-%dT%H:%M:%SZ") | |
| # V2: Verb + Date + Resource + AccessKey (no host URL) | |
| local STS=$(printf '%s\n%s\n%s\n%s' \ | |
| "$METHOD" "$DATE" "$URI" "$ACCESS_KEY") | |
| local SIG=$(printf '%s' "$STS" \ | |
| | openssl dgst -sha256 -hmac "$SECRET_KEY" -binary | openssl base64) | |
| curl -s -X "$METHOD" "${CMOD_HOST}${URI}" \ | |
| -H "usi-date: $DATE" \ | |
| -H "Authorization: CMODSharedKeyV2 ${ACCESS_KEY}:${SIG}" \ | |
| ${BODY:+-H "Content-Type: application/json" -d "$BODY"} | |
| } | |
| # ── Test ────────────────────────────────────────────────── | |
| echo "=== V1 ping ===" | |
| cmod_curl_v1 GET /cmod-rest/v1/ping | jq . | |
| echo "=== V2 ping ===" | |
| cmod_curl_v2 GET /cmod-rest/v1/ping | jq . | |
| ####only V2 example below | |
| #!/bin/bash | |
| CMOD_HOST="http://vfcmod105.mydom.com:9085" | |
| ACCESS_KEY="odrestapi1-R____2A" | |
| SECRET_KEY="iH_____pQS" | |
| # ── CMODSharedKeyV2 helper ──────────────────────────────── | |
| cmod() { | |
| local METHOD="$1" URI="$2" BODY="${3:-}" | |
| local DATE=$(date -u "+%Y-%m-%dT%H:%M:%SZ") | |
| local SIG=$(printf '%s\n%s\n%s\n%s' "$METHOD" "$DATE" "$URI" "$ACCESS_KEY" \ | |
| | openssl dgst -sha256 -hmac "$SECRET_KEY" -binary | openssl base64) | |
| curl -s -X "$METHOD" "${CMOD_HOST}${URI}" \ | |
| -H "usi-date: $DATE" \ | |
| -H "Authorization: CMODSharedKeyV2 ${ACCESS_KEY}:${SIG}" \ | |
| ${BODY:+-H "Content-Type: application/json" -d "$BODY"} | |
| } | |
| ## simple ping | |
| cmod GET /cmod-rest/v1/ping | |
| ## folders | |
| cmod GET /cmod-rest/v1/folders | jq . | |
| ## folder details | |
| cmod GET /cmod-rest/v1/folders/SAPDOCF1 | jq . | |
| ## app groups (doc classes) | |
| cmod GET /cmod-rest/v1/appgroup | jq . | |
| ## app group detail | |
| cmod GET /cmod-rest/v1/appgroup/sapdocs | jq . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment