Skip to content

Instantly share code, notes, and snippets.

@watahani
Last active October 20, 2021 06:49
Show Gist options
  • Save watahani/546d21ce1f0368bb90c6ab517843134e to your computer and use it in GitHub Desktop.
Save watahani/546d21ce1f0368bb90c6ab517843134e to your computer and use it in GitHub Desktop.
$clientId = '<client-id>'
$clientSecret = '<client-secret>'
$tenantId = "<your-tenant-id>"
$scope = 'https://graph.microsoft.com/.default'
$tokenEndpoint = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
$postParams = @{
client_id = $clientId;
client_secret = $clientSecret;
grant_type = 'client_credentials';
scope = $scope
}
$authResult = (Invoke-WebRequest -Uri $tokenEndpoint -Method POST -ContentType "application/x-www-form-urlencoded" -Body $postParams) | ConvertFrom-Json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment