【问题标题】:System.TypeInitializationException: The type initializer for 'Microsoft.IdentityModel.Clients.ActiveDirectory.Authenticator' threw an exceptionSystem.TypeInitializationException:“Microsoft.IdentityModel.Clients.ActiveDirectory.Authenticator”的类型初始化程序引发异常
【发布时间】:2018-09-01 08:51:14
【问题描述】:

我正在尝试从 Dynamics 365 插件执行 S2S 身份验证,但目前未成功。出现以下异常:

System.TypeInitializationException: The type initializer for 'Microsoft.IdentityModel.Clients.ActiveDirectory.Authenticator' threw an exception

我的理解是,在加载 IdentityModel dll 时会引发异常,即使在运行时也不会。但是,如果这很重要,这就是我们在代码中所做的:

var clientCreds = new ClientCredential(clientId, secret);

AuthenticationContext authContext = new AuthenticationContext(authorityUri);
AuthenticationResult authResult = authContext.AcquireTokenAsync(resource, clientCreds).GetAwaiter().GetResult();

我们正在使用以下软件包:

相同的代码可以在控制台应用中使用。非常感谢任何帮助/建议。

【问题讨论】:

  • 你想 S2S 做什么?
  • 到 Azure 中的 Web api 服务

标签: authentication dynamics-crm adal server-to-server


【解决方案1】:

这可能是因为您在沙盒中运行。虽然 MSDN 没有明确建议不要这样做,但它建议您只连接到匿名服务。

Plug-in isolation, trusts, and statistics

沙盒中禁止访问文件系统、系统事件日志、某些网络协议、注册表等。

...

沙盒插件和自定义工作流活动可以访问 通过 HTTP 和 HTTPS 协议的网络....以下网页 访问限制适用于此沙盒功能。

  • 支持并建议使用匿名身份验证。

【讨论】:

    猜你喜欢
    • 2015-08-31
    • 2017-08-17
    • 1970-01-01
    • 2016-11-30
    • 2021-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多