' AuthenticationBuilder'不包含有关AddMicrosoftityWebapp'的定义。
我正在尝试将对图的支持添加到.NET 6应用程序中。我以前在.NET 5应用程序中使用了Graph,但是我很难使用.NET 6“ Simplifiend”启动来了解如何将事物汇总。
我两者都包括:
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
program.cs的标题
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
.AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi"))
.AddInMemoryTokenCaches();
中
Error CS1061 'AuthenticationBuilder' does not contain a definition for 'AddMicrosoftIdentityWebApp' and no accessible extension method 'AddMicrosoftIdentityWebApp' accepting a first argument of type 'AuthenticationBuilder' could be found (are you missing a using directive or an assembly reference?)
在 忽略一些简单的东西,但我找不到。
任何建议都非常感谢。
I'm attempting to add support for Graph into a .Net 6 application. I've previously used Graph in a .Net 5 application but I'm having some trouble understanding how to wire things up using the .Net 6 "simplified" startup.
I've included both:
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
in the header of Program.cs but I'm getting an error with AddMicrosoftIdentityWebApp in the following:
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
.AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi"))
.AddInMemoryTokenCaches();
The error I'm getting is:
Error CS1061 'AuthenticationBuilder' does not contain a definition for 'AddMicrosoftIdentityWebApp' and no accessible extension method 'AddMicrosoftIdentityWebApp' accepting a first argument of type 'AuthenticationBuilder' could be found (are you missing a using directive or an assembly reference?)
I'm fairly sure that I'm overlooking something pretty simple, but I cannot find it.
Any suggestions are much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要解决上述错误,请尝试以下建议,如果有用:
当您包括
Microsoft.Identity.web
,时Microsoft.Identity.web.ui
软件包,这些库用于简化登录用户的过程并为Microsoft Graph获取令牌。尝试修改您的 配置的服务方法 ,通过删除前缀
builder
如下:登录a使用Microsoft Identity Platform endpoint
Addmicrosoftitywebapp()
的用户。enableTokenAcquesitionTocallDownStreamapi()
和addmicrosoftgraph
添加支持呼叫Microsoft Graph的支持。否则,如果要使用
Builder
,请确保使用microsoft.aspnetcore.sideity 并定义
建筑商
如下:有关更多详细信息,请请参阅下面的链接 links:
active-directory-aspnetcore-webapp-openidConnect-v2/readme.md at master·azure-samples/active-directory-aspnetcore-webapp-openidconnect-connect-v2-v2·github 。
|微软文档。
To resolve the above error, please try the below suggestions if helpful:
When you are including
Microsoft.Identity.Web
,Microsoft.Identity.Web.UI
packages, these libraries are used to simplify the process of signing-in a user and acquiring tokens for Microsoft Graph.Try modifying your configured services method by removing the prefix
builder
like below:To sign-in a user for your application with Microsoft identity platform endpoint
AddMicrosoftIdentityWebApp()
is used.EnableTokenAcquisitionToCallDownstreamApi()
andAddMicrosoftGraph
adds support to call Microsoft Graph.Otherwise, If you want to use
builder
, make sure to add the package usingMicrosoft.AspNetCore.Identity
and define thebuilder
as below:For more in detail, please refer below links:
active-directory-aspnetcore-webapp-openidconnect-v2/README.md at master · Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2 · GitHub.
Configure ASP.NET Core Identity | Microsoft Docs.
感谢您的回复。
事实证明,我发现问题出在安装了不正确的软件包。我已将 Decos.Microsoft.Indentity.Web 包含在解决方案的包中。我怀疑这里发生了一些碰撞。一旦我删除了包,错误就不再出现。
Thanks for the response.
As it turns out, I found that the problem was with an incorrect package being installed. I had included Decos.Microsoft.Indentity.Web in the packages for the solution. I suspect that there were some collisions occurring here. Once I removed the package the error no longer manifests itself.