【发布时间】:2020-01-30 07:10:12
【问题描述】:
我正在尝试通过 Azure API 网关生成 Active Directory 令牌。为此,我在我的 Azure API 网关上创建了一个 API 操作,它接受以下主体参数。
{
"client_id" :"****************",
"scope":"https://graph.windows.net/.default",
"client_secret":"****************",
"grant_type":"client_credentials"
}
每当我尝试对此进行测试时,都会为入站进程设置正文,但无法将其转发到后端服务,即 https://login.microsoftonline.com/{{ID}}/oauth2/v2.0/token/ 所以我修改了我的入境政策如下,但仍然没有运气。
<set-method>POST</set-method>
<set-variable name="requestBodyData" value="@(context.Request.Body.As<string>(preserveContent: true))" />
<set-header name="Content-Type" exists-action="override">
<value>"application/x-www-form-urlencoded"</value>
</set-header>
<rewrite-uri template="/" />
<set-body>@{
return "client_id=*******&scope=https://graph.windows.net/.default&client_secret=*******&grant_type=client_credentials";
}</set-body>
<!-- Don't expose APIM subscription key to the backend. -->
<set-header name="Ocp-Apim-Subscription-Key" exists-action="delete" />
任何潜在客户都会得到认可。
【问题讨论】:
标签: azure azure-active-directory azure-api-management api-management