github.com/jstaf/onedriver@v0.14.2-0.20240420231225-f07678f9e6ef/curl-graph.sh (about) 1 #!/usr/bin/env bash 2 if [ -z "$1" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then 3 echo "curl-graph.sh is a dev tool useful for exploring the Microsoft Graph API via curl." 4 echo 5 echo "$(tput bold)Usage:$(tput sgr0) ./curl-graph.sh [auth-token-file] api_endpoint [other curl options]" 6 echo "$(tput bold)Example:$(tput sgr0) ./curl-graph.sh ~/.cache/onedriver/auth_tokens.sh /me" 7 exit 0 8 fi 9 10 if [ -f "$1" ]; then 11 TOKEN=$(jq -r .access_token "$1") 12 ENDPOINT="$2" 13 shift 2 14 else 15 TOKEN=$(jq -r .access_token ~/.cache/onedriver/auth_tokens.json) 16 ENDPOINT="$1" 17 shift 1 18 fi 19 20 curl -s -H "Authorization: bearer $TOKEN" $@ "https://graph.microsoft.com/v1.0$ENDPOINT" | jq .