How To Get Microsoft Graph API Token Using PowerShell

UPDATE: This is now available as a module
https://www.powershellgallery.com/packages/Office365TokenGet

One of the things that I had difficulty with when I was starting to work with MS Graph API was how to get authenticated. So here is a post that hopefully would help others start their coding with MS Graph API.

This simple function helps you get a pre-authenticated token.

The Function Code



The Function in Action


Note that I already have an App registered in Azure AD. This means that I already have the Client ID, Client Secret, and the Tenant Domain.

I will not cover the Azure App Registration in this post.

Define Required Parameter Values with Variables


Acquire Token


Retrieve User Profile



That's the end of this simple demonstration on how to get MSGraph API Token using PowerShell.

Share:

No comments:

Post a Comment

Popular Posts

Powered by Blogger.