简体   繁体   English

如何使用不记名令牌授权一个 Azure Active Directory 应用程序访问不同的 AAD 应用程序服务 Web API?

[英]How do I authorize one Azure Active Directory app to access a different AAD App Service Web API using a Bearer token?

I've been searching for a couple days, and I can't seem to find a straightforward guide on how to set up Authorization (AuthZ) between an AAD App and my AAD Web API set up in App Service.我已经搜索了几天,似乎找不到关于如何在应用服务中设置 AAD 应用程序和我的 AAD Web API 之间设置授权 (AuthZ) 的简单指南。 I've tried things like this official guide , but I can't seem to get calls with a Bearer token from the client app to work.我已经尝试过类似这个官方指南的东西,但我似乎无法从客户端应用程序中获得带有 Bearer 令牌的调用。

Has anyone done this successfully?有没有人成功做到这一点? Is there a step by step guide out there that could help?是否有分步指南可以提供帮助?

Please let me know if there are any questions!如果有任何问题,请告诉我!

To implement your requirements, you need to expose an api in your AAD Web API first.要实现您的要求,您需要首先在您的 AAD Web API 中公开一个 api。 在此处输入图像描述

Then go to your AAD App which used to request the token, add the permission to it.然后 go 到您用于请求令牌的 AAD 应用程序,为其添加权限。 在此处输入图像描述

在此处输入图像描述

Click "Grant admin consent for *" button.单击“授予管理员同意 *”按钮。 在此处输入图像描述

After that, we can request the access token successfully (below I provide a sample use password flow for your reference)之后,我们就可以成功请求访问令牌了(下面我提供了一个示例使用密码流程供您参考) 在此处输入图像描述

In your Web API app, you need to parse the access token and get the scope permission from the access token.在您的 Web API 应用程序中,您需要解析访问令牌并从访问令牌中获取 scope 权限。 And then determine whether the request has permission.然后判断请求是否有权限。

暂无
暂无

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

相关问题 如何从 Azure Active Directory (AAD) Web API 检索 access_token - How to retrieve access_token from Azure Active Directory (AAD) Web API 如何授权服务使用 Azure Active Directory 调用 API? - How do I authorize a service to call an API using Azure Active Directory? 使用 MSI 通过 AAD 访问 Azure web 应用程序 web 服务 - Access Azure web app web service through AAD using MSI 我的 ASP.NET 核心应用服务 Web API 如何支持 AAD 承载令牌和客户端证书身份验证? - How can my ASP.NET Core App Service Web API support both AAD Bearer Token and Client Certificate Auth? 授权angular.js应用程序访问由Azure Active Directory身份验证保护的Web API 2项目 - Authorize an angular.js app to access a Web API 2 project secured by Azure Active Directory auth 在Azure Web App中针对AAD使用Active Directory密码时,“不支持关键字:身份验证” - “Keyword not supported: authentication” when using Active Directory Password against AAD in Azure Web App 在AAD安全Azure Web App中检索访问令牌 - Retrieve Access Token within a AAD secured Azure Web App 使用 Azure Active Directory 在不同租户上访问 Azure Service Fabric 应用程序上的 Key Vault - Access Key Vault on Azure Service Fabric app using Azure Active Directory on different tenant 无法使用承载令牌访问AAD安全Web API - Unable to use bearer token to access AAD-secure Web API 如何使用 Azure Active Directory 在 Web 应用程序中刷新访问令牌 - How to refresh access token in web application using Azure Active Directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM