-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathcurl-graph.sh
More file actions
executable file
·20 lines (18 loc) · 707 Bytes
/
curl-graph.sh
File metadata and controls
executable file
·20 lines (18 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
if [ -z "$1" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
echo "curl-graph.sh is a dev tool useful for exploring the Microsoft Graph API via curl."
echo
echo "$(tput bold)Usage:$(tput sgr0) ./curl-graph.sh [auth-token-file] api_endpoint [other curl options]"
echo "$(tput bold)Example:$(tput sgr0) ./curl-graph.sh ~/.cache/onedriver/auth_tokens.sh /me"
exit 0
fi
if [ -f "$1" ]; then
TOKEN=$(jq -r .access_token "$1")
ENDPOINT="$2"
shift 2
else
TOKEN=$(jq -r .access_token ~/.cache/onedriver/auth_tokens.json)
ENDPOINT="$1"
shift 1
fi
curl -s -H "Authorization: bearer $TOKEN" $@ "https://graph.microsoft.com/v1.0$ENDPOINT" | jq .