Open TomonoriSoejima opened 11 months ago
client_id=$(az ad app list --query "[].{appId:appId}" | jq -r '.[].appId')
tenant=$(az account show --query tenantId --output tsv)
secret=$(az ad app credential reset --id $client_id --only-show-errors | jq -r .password)
sleep 10
base_64=$(printf "%s:%s" $client_id $secret | base64)
TOKEN=$(curl -s -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic $base_64" \
-d "grant_type=client_credentials&scope=https%3A%2F%2Fmanage.office.com%2F.default" \
https://login.microsoftonline.com/$tenant/oauth2/v2.0/token | jq -r .access_token)
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Length: 0" \
"https://manage.office.com/api/v1.0/$tenant/activity/feed/subscriptions/start?contentType=DLP.All&PublisherIdentifier=$tenant"
client_id=$(az ad app list --query "[].{appId:appId}" | jq -r '.[].appId')
echo "az ad sp list --display-name "Office 365 Management APIs" | jq '.[] | {appDisplayName, appId}'"
az ad sp list --display-name "Office 365 Management APIs" | jq '.[] | {appDisplayName, appId}'
echo "az ad sp list --display-name "Office 365 Management APIs" | jq '.[].oauth2PermissionScopes[] | select (.isEnabled == true)'"
az ad sp list --display-name "Office 365 Management APIs" | jq '.[].oauth2PermissionScopes[] | select (.isEnabled == true)'
echo "az ad app show --id $client_id | jq .requiredResourceAccess"
az ad app show --id $client_id | jq .requiredResourceAccess
https://zenn.dev/masakikato/articles/o365-managementapi-quickstart
The Microsoft 365 APIs provide access to various services within Microsoft 365, including Outlook, OneDrive, SharePoint, and more. If you want to test the Microsoft 365 API, you'll need to follow these general steps:
Register an Azure AD Application:
Application (client) ID
,Directory (tenant) ID
, andObject ID
.Set up Permissions:
Generate a Client Secret:
Get an Access Token:
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
, with the required parameters like client_id, scope, client_secret, etc.Make API Calls:
https://graph.microsoft.com/v1.0/me/
.Testing:
Note: Remember to always keep your client secrets and access tokens secure. Do not expose them or share them.
Would you like to see an example in Python on how to obtain an access token and make a sample API call, or do you need help with a specific step?