【问题标题】:Azure APIM 302 Moved temporarily error how to fix it?Azure APIM 302 临时移动错误如何解决?
【发布时间】:2023-02-15 16:11:33
【问题描述】:

尝试制定一项政策,通过将发送请求粘贴在授权标头中来获取不记名令牌,然后将 JSON 数据发布到给定的后端。

但是当我在 Azure 的测试选项卡中测试它时,我总是收到相同的错误:

即使我添加 <forward-request timeout="60" follow-redirects="60"/> 它也不起作用。 我也尝试过不使用默认为 false 的 follow-redirects 但也没有效果。

我是 Azure 的新手,因此我们将不胜感激。

这是我的政策:

<policies>
    <inbound>
        <base />
        <send-request ignore-error="true" timeout="20" response-variable-name="bearerToken" mode="new">
            <set-url>{{AuthenticationServer}}</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-header name="Authorization" exists-action="override">
                <value>Basic {{Base64encodedusernamepassword}}</value>
            </set-header>
            <set-body>@{
              return "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" /> -->
        <set-backend-service base-url="{{BaseURI}}" />
    </inbound>
    <backend>
        <forward-request timeout="60" follow-redirects="true" />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>

【问题讨论】:

  • 是的,问题已解决,提供我帐户的公司没有给我 VPN 访问权限。这是测试端点所必需的。
  • 我不知道这是否是你的情况,但如果你的 APIM 是内部 Vnet,而之前它是在外部 Vnet 中,你也会收到此错误。
  • 是的,我不确定他们是如何设置 Vnet 的。但我很确定它现在是内部的,所以 VPN 为我解决了这个问题

标签: azure azure-devops azure-api-management


【解决方案1】:

问题是端点位于私有 VNet 后面,因此获得 VPN 访问权限解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多