PlatformPlugin异常在ASP.NET Core中使用MSAL获取仅应用程序令牌(PlatformPlugin exception getting app

编程入门 行业动态 更新时间:2024-10-27 04:31:15
PlatformPlugin异常在ASP.NET Core中使用MSAL获取仅应用程序令牌(PlatformPlugin exception getting app-only token using MSAL in ASP.NET Core)

我正在尝试创建一个使用MSAL作为客户端凭据流的ASP.NET Core应用程序。

尝试获取访问令牌时出现以下异常:

NullReferenceException: Object reference not set to an instance of an object. Microsoft.Identity.Client.Internal.PlatformPlugin.LoadPlatformSpecificAssembly()

以下示例验证身份验证: active-directory-dotnet-webapp-openidconnect-aspnetcore-v2

授权模仿此示例: active-directory-dotnet-daemon-v2

我的应用程序已注册Mail.Read应用程序权限。 以下是引发异常的代码:

string authority = $"https://login.microsoftonline.com/{ tenantId }/v2.0"; ConfidentialClientApplication client = new ConfidentialClientApplication( authority, appId, redirectUri, new ClientCredential(appSecret), null);//new TokenCache()); AuthenticationResult authResult = await client.AcquireTokenForClient( new string[] { "Mail.Read" }, null); return authResult.Token;

还尝试使用“ https://graph.microsoft.com/.default ”作用域,如守护程序示例中所示。

I'm trying to create an ASP.NET Core app that uses MSAL for the client credentials flow.

I get the following exception when trying to get an access token:

NullReferenceException: Object reference not set to an instance of an object. Microsoft.Identity.Client.Internal.PlatformPlugin.LoadPlatformSpecificAssembly()

Authentication is modeled after this sample: active-directory-dotnet-webapp-openidconnect-aspnetcore-v2

Authorization is modeled after this sample: active-directory-dotnet-daemon-v2

My app is registered with the Mail.Read Application permission. Here's the code that throws the exception:

string authority = $"https://login.microsoftonline.com/{ tenantId }/v2.0"; ConfidentialClientApplication client = new ConfidentialClientApplication( authority, appId, redirectUri, new ClientCredential(appSecret), null);//new TokenCache()); AuthenticationResult authResult = await client.AcquireTokenForClient( new string[] { "Mail.Read" }, null); return authResult.Token;

Also tried with "https://graph.microsoft.com/.default" scope, as in the daemon sample.

最满意答案

回答这个问题。 我在GitHub仓库中将其作为问题打开 。 它以下列答复结束:

这个问题在下一个版本中不会发生,因为我们将转向单个二进制。

Answering this question. I opened this as an issue on the GitHub repo. It was closed with the following response:

this problem will not occur with the next release as we will move to a single binary.

更多推荐

本文发布于:2023-07-17 13:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145025.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   应用程序   异常   NET   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!