【发布时间】:2018-01-18 20:06:27
【问题描述】:
我正在尝试将我的 api 连接到 dynamics 365 crm。当我使用邮递员获取令牌时,我可以访问,但是当我使用 ADAL 获取令牌时,请求返回 401 未授权。 如果我在我的应用程序上对邮递员获得的令牌进行硬编码,它就可以正常工作。 我看到邮递员返回给我 ADALnot 的信息(如 refresh_token、token_id)
使用 ADAL 获取令牌
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);
【问题讨论】:
-
您解决了这个问题吗?我有同样的问题,虽然我想责怪 Dynamics 团队,但我怀疑真正的罪魁祸首是 Azure AD 和 ADAL 团队
标签: azure authentication token postman adal