'Service Principal Authentication to Microsoft Dynamics 365 API issue

For the life of me I cannot figure this out. I am trying to write a PowerShell Script that will get a list of solutions in a tenant

The Url to do this is as following: https://(MyCRM).dynamics.com/api/data/v9.x/solutions

Service principal items I have are: ClientId, ApplicationId, ClientSecret

In my case I am using Invoke-WebRequest

How do I build the Authentication part of the Invoke-WebRequest, to successfully get the request through?



Solution 1:[1]

so someone pointed me to a solution :) basically its a two step process:

  1. you get the access token from https://login.microsoftonline.com
  2. than you use the token in your authorisation header for any calls you do to the server

Solution

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 OOIOIOO