在Azure APIM中设置sharepoint rest api作为后端



我们正在尝试在Azure apim后端设置sharepoint rest api。我们制定了以下apim政策。它正在接收客户端令牌,但无法在共享点中成功执行rest调用。我不确定我们是否走在正确的轨道上。任何意见都将不胜感激。非常感谢。

<send-request ignore-error="true" timeout="20" response-variable-name="bearerToken" mode="new">
<set-url>{{authorizationServer}}</set-url>
<set-method>POST</set-method>
<set-header name="Content-Type" exists-action="override">
<value>application/x-www-form-urlencoded</value>
</set-header>
<set-body>@{
return "client_id={{clientId}}&scope={{scope}}&client_secret={{clientSecret}}&grant_type=client_credentials";
// For Azure AD v1, try return statement below
// return "client_id={{clientId}}&resource={{scope}}&client_secret={{clientSecret}}&grant_type=client_credentials";
}</set-body>
</send-request>
<set-header name="Authorization" exists-action="override">
<value>@("Bearer " + (String)((IResponse)context.Variables["bearerToken"]).Body.As<JObject>()["access_token"])</value>
</set-header>
<!--  Don't expose APIM subscription key to the backend. -->
<set-header name="Ocp-Apim-Subscription-Key" exists-action="delete" />
  • 在调用后端服务之前,我们需要启动一个APIM提供发送请求的请求,您可以在策略中使用该请求以及C#表达式。

  • 此外,您还可以浏览此文档,其中包含有关Access令牌的详细信息。

  • 由于您已经生成令牌,只需检查应用程序是否通过足够的权限授予

  • 有关SharePoint Rest API的完整详细信息,请参阅本文档和本MS Q&讨论。

最新更新