Now that MF auth is required, I can't seem to figure out how to make an Azure REST API call from a console application (.Net Core). I've tried multiple samples, however none of them seem to work.
string authContextURL = "https://login.windows.net/" + TenantID;
var authenticationContext = new AuthenticationContext(authContextURL);
var credential = new ClientCredential(ClientID, ClientSecret);
var result = authenticationContext.AcquireTokenAsync("https://management.azure.com/", credential).GetAwaiter().GetResult();
if (result == null)
{
throw new InvalidOperationException("Failed to obtain the JWT token");
}
string token = result.AccessToken;
return token;
Error: "The received access token is not valid: at least one of the claims 'puid' or 'altsecid' or 'oid' should be present. If you are accessing as application please make sure service principal is properly created in the tenant."
In addition, setting up the Service Principal (or whatever is required) has also changed.
Is there a walk-through and code for getting the Service Principal setup and a console application able to call Azure REST APIs?
Thank you.