Authentication refactoring.
This commit is contained in:
29
scripts/sample-az-graph-devops.sh
Executable file
29
scripts/sample-az-graph-devops.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Hardcode variables.
|
||||
SUBSCRIPTION_ID="c885a276-c882-483f-b216-42f73715161d"
|
||||
|
||||
ACCESS_TOKEN=$(sk-az-tools get-token graph)
|
||||
|
||||
|
||||
# List Azure resource groups via Azure Resource Manager API
|
||||
echo "Azure Resource Groups in subscription '$SUBSCRIPTION_ID':"
|
||||
curl -sSL -H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
"https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourcegroups?api-version=2021-04-01" |
|
||||
jq '.value[] | {id, name, location}'
|
||||
|
||||
echo "---"
|
||||
|
||||
# Get current user ('me') via Microsoft Graph
|
||||
echo "Current User (me):"
|
||||
curl -sSL -H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
"https://graph.microsoft.com/v1.0/me" |
|
||||
jq '{id, displayName, userPrincipalName}'
|
||||
|
||||
echo "---"
|
||||
|
||||
# List Azure DevOps projects in the given org
|
||||
echo "Azure DevOps Projects in org 'skoszewski':"
|
||||
curl -sSL -H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
"https://dev.azure.com/skoszewski/_apis/projects?api-version=7.1" |
|
||||
jq '.value[] | {id, name, state}'
|
||||
Reference in New Issue
Block a user