I have written the following code to acquire token for CRM.
class Program
{
private const string username = "richa@azuretraining112.onmicrosoft.com";
private const string password = "Pa$$w0rd";
private const string serviceURL = "https://azuretraining112.crm8.dynamics.com";
private const string applicationID = "89a70b76-3a71-481f-8755-a7aa97c59c35";
private const string redirectURL = "https://localhost1";
private const string authorityURI = "https://login.microsoftonline.com/1d54ea41-cd25-488f-812c-c078e6114065/oauth2/authorize";
private static AuthenticationResult authResult = null;
private static void Main(string[] args)
{
var credentials = new UserPasswordCredential(username, password);
var context = new AuthenticationContext(authorityURI);
authResult = context.AcquireTokenAsync(serviceURL, applicationID, credentials).Result;
}
}
But, while running the code, I am getting the following error while trying to get the token using AcquireTokenAsync.
I have added an application user using the application ID :
I don't know what I am missing. Please help!
I tried with the solution given in Tenant not authorized, but, nothing worked.
Thanks!