简体   繁体   English

Azure 逻辑应用程序 HTTP 请求身份验证 Scope

[英]Azure Logic App HTTP Request Authentication Scope

We have an API hosted in Azure as an Azure Web App that we need to trigger via http on a schedule.我们有一个 API 托管在 Azure 作为 Azure Web 我们需要按计划通过 http 触发的应用程序。

Our API requires a valid Azure AD Access Token be sent with each request.我们的 API 要求在每个请求中发送一个有效的 Azure AD 访问令牌。

Azure Logic Apps gives us the option to authenticate our request with Azure AD. Azure 逻辑应用程序让我们可以选择使用 Azure AD 来验证我们的请求。 However, we do not see the option of including scope in the request.但是,我们没有看到在请求中包含 scope 的选项。 If we send a request without specified scope or role, we get the following error:如果我们在没有指定 scope 或角色的情况下发送请求,我们会收到以下错误:

System.UnauthorizedAccessException: IDW10201: Neither scope or roles claim was found in the bearer token.

在此处输入图像描述

How can we authenticate an http request from an Azure Logic App when scope/role is required in the access token by the API?当 API 在访问令牌中需要范围/角色时,我们如何验证来自 Azure 逻辑应用程序的 http 请求?

Thanks to @Skin for the suggestion!感谢@Skin 的建议!

Here is what worked for future visitors to this question:以下是对这个问题的未来访问者有效的方法:

Navigate to your Logic App in the Azure Portal > Select "Logic App Code View" > Add the following to "authentication":在 Azure 门户中导航到您的逻辑应用 > Select“逻辑应用代码视图”> 将以下内容添加到“身份验证”:

在此处输入图像描述

  • audience: "api://<your api's clientId>"观众:“api://<您的 api 的 clientId>”
  • clientId: "<your logic app's clientId>" clientId: "<你的逻辑应用的 clientId>"
  • scope: "api://<your api's clientId>/.default" (this piece is not available in the interface) scope: "api://<your api's clientId>/.default" (界面中没有这块)
  • secret: "the secret you generated for your logic app in your aad app registration"秘密:“您在 aad 应用程序注册中为逻辑应用程序生成的秘密”
  • tenant: "your tenant id"租户:“您的租户ID”

Parameter " Audience " is the scope. Depending on how you built your target api and what is expected there as audience in token you could probably have there somehting like: api://<yoru_app_id>/.default, but you should know it best.参数“ Audience ”是 scope。根据您构建目标 api 的方式以及作为令牌中的观众的预期内容,您可能会看到类似的内容:api://<yoru_app_id>/.default,但您应该最了解它. Eg when you call Graph MS your scope/resource/audience here is: https://graph.microsoft.com/.default , but different APIs have different needs for scopes.例如,当您调用 Graph MS 时,您的范围/资源/受众是: https://graph.microsoft.com/.default ,但不同的 API 对范围有不同的需求。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM