简体   繁体   English

如何使用 OAuth 和一个 WebAPI 对不同类型的应用程序进行身份验证

[英]How to authenticate different type of applications using OAuth and one WebAPI

I have a WPF client application and AngularJs client connecting to the same Web API to get\\send data.我有一个 WPF 客户端应用程序和 AngularJs 客户端连接到同一个 Web API 来获取\\发送数据。
I want to apply OAuth with Azure as identity provider.我想将 OAuth 与 Azure 作为身份提供者一起应用。
What I want is to use this single Web API that both of the applications calling, not to create separate APIs for each.我想要的是使用这两个应用程序调用的单个 Web API,而不是为每个应用程序创建单独的 API。

Thanks谢谢

I found a solution,我找到了解决办法,
When you want to authenticate SPA app & WPF and both of them using the same WebAPI you'll face a problem, that in SPA case (see this sample ), in the server side (WebAPI) in the Startup.ConfigureAuth you need to set Audience property same as ClientId, but when you need to apply OAuth with WPF (native client, see this sample ) you'll need to provide it as "App ID URI".当您想验证 SPA 应用程序和 WPF 并且它们都使用相同的 WebAPI 时,您将面临一个问题,即在 SPA 情况下(请参阅此示例),在服务器端 (WebAPI) 中的Startup.ConfigureAuth您需要设置Audience 属性与 ClientId 相同,但是当您需要使用 WPF(本机客户端,请参阅此示例)应用 OAuth 时,您需要将其提供为“App ID URI”。

You solve this by adding the code from the first sample and the code from the second both in your Startup.ConfigureAuth method in your project.您可以通过在项目的Startup.ConfigureAuth方法中添加第一个示例中的代码和第二个示例中的代码来解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用WebApi通过ADFS进行身份验证 - Using WebApi to authenticate with ADFS 如何使用具有来自 C# 可执行文件的“authentication_code”授权流类型的 OAuth 2.0 进行身份验证? - How to authenticate using OAuth 2.0 with `authentication_code` grant flow type from a C# executable? 如何使用来自WebAPI的域的用户对WebAPI上不同计算机上的客户端进行身份验证? - how can authenticate a client on a different machine on a WebAPI with a user from WebAPI's domain? 如何在WebApi中验证XboxLive用户 - How to authenticate XboxLive user in WebApi 使用OAuth验证EWS应用程序 - Authenticate an EWS application by using OAuth 如何使用OAuth 2.0对Azure Active Directory进行身份验证? - How to authenticate user with Azure Active Directory using OAuth 2.0? 如何通过OAuth在WebApi中使用声明 - How to use claims in WebApi with OAuth Webapi具有针对不同用户的多个oauth令牌 - Webapi with multiple oauth tokens for different users 如何从托管在单独服务器上的前端客户端使用 Windows Active Directory 对 .Net Core WebAPI 中的用户进行身份验证? - How to authenticate a user in a .Net Core WebAPI using Windows Active Directory from a frontend client that is hosted on a separate server? 如何对从C#控制台应用程序使用表单身份验证的ASP.NET WebAPI进行身份验证? - How can I authenticate to an ASP.NET WebAPI that is using Forms Authentication From a C# Console Application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM