我编写了以下代码来获取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;
}
}
但是,在运行代码时,尝试使用AcquireTokenAsync获取令牌时出现以下错误。
我不知道我在想什么。请帮忙!
我尝试了Tenant not authorized中给出的解决方案,但是没有任何效果。
谢谢!
答案 0 :(得分:2)
使用端口号“ https://localhost1:5000”配置此URL,并在Azure AD的答复URL中配置相同的“ https://localhost1:5000”。
让我知道这是否可行