Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#get Access Token
$body = "grant_type=authorization_code&redirect_uri=$redirectUri&client_id=$clientId&client_secret=$clientSecretEncoded&code=$authCode&resource=$resource"
$Authorization = Invoke-RestMethod https://login.microsoftonline.com/common/oauth2/token `
-Method Post -ContentType "application/x-www-form-urlencoded" `
-Body $body `
-ErrorAction STOP
Write-output $Authorization.access_token
$accesstoken = $Authorization.access_token
$me = Invoke-RestMethod -Headers @{Authorization = "Bearer $accesstoken"} `
-Uri https://graph.microsoft.com/v1.0/me `
-Method Get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.