Last active
May 19, 2020 12:30
-
-
Save bruceharrison1984/019e972405c03c61b9a99c3c5c7312be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Fields = @{ | |
grant_type = "client_credentials" | |
client_id = "<service-principal-id>" | |
resource = "<resource-id-to-auth-for-or-url>" | |
client_secret = "<service-principal-secret>" | |
}; | |
$response = Invoke-RestMethod ` | |
-Uri "https://login.microsoftonline.com/<azure-tenant-id>/oauth2/token" ` | |
-ContentType "application/x-www-form-urlencoded" ` | |
-Method POST ` | |
-Body $Fields; | |
Write-Output $tokenResponse.access_token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment