我正在尝试将我的API连接到Dynamics 365 CRM。 当我使用postman获取令牌时,我可以访问,但是当我使用ADAL获取令牌时,请求返回401未经授权。
如果我在应用程序中硬编码使用postman获得的令牌,则可以正常工作。
我看到postman返回给我的信息,ADAL没有(例如refresh_token,token_id)。
string resource = "https://******.crm2.dynamics.com/";
string clientId = "**************";
string clientSecret = "************";
string authority = "https://login.microsoftonline.com/*****/oauth2/authorize";
ClientCredential credential = new ClientCredential(clientId, clientSecret);
AuthenticationContext authContext = new AuthenticationContext(authority, true);
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, credential);