Skip to content

Authenticate with and call the Microsoft Graph

Author: Garry Trinder

Calling the Microsoft Graph can be done using the m365 request command.

m365 request --url

Another route would be to use shell-specific webrequest tooling. To do this, obtain a new access token for the Microsoft Graph and use it in an HTTP request.

$token = m365 util accesstoken get --resource --new --output text
$me = Invoke-RestMethod -Uri -Headers @{"Authorization"="Bearer $token"}

# requires jq:

token=`m365 util accesstoken get --resource --new --output text`
me=`curl -H "Authorization: Bearer $token"`
echo $me | jq