我正在尝试创建一个使用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.
更多推荐
发布评论