微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用组织帐户从Excel访问API Management API

如何解决使用组织帐户从Excel访问API Management API

在我们的组织中,有些人使用Excel来访问我们的API。我们希望这些API通过API管理公开,并使用Azure Active Directory进行身份验证。

在excel中,可以通过使用“组织帐户”来实现,但是目前我收到消息“我们无法使用提供的凭据进行身份验证。请重试”。

excel-enter-api-url

excel-use-organizational-account

我已遵循此guide来设置Active Directory注册应用程序并相应地配置API管理。

要做的另一步骤是在API管理配置中的下面添加“ WWW-Authenticate”标头,以触发Excel对我们的AD租户进行身份验证:

<policies>
<inbound>
    <base />
    <validate-jwt header-name="Authorization" Failed-validation-httpcode="401" Failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
        <openid-config url="https://login.microsoftonline.com/<tenant-id>/v2.0/.well-kNown/openid-configuration" />
        <required-claims>
            <claim name="aud">
                <value>expected-aud</value>
            </claim>
        </required-claims>
    </validate-jwt>
</inbound>
<backend>
    <base />
</backend>
<outbound>
    <base />
</outbound>
<on-error>
    <choose>
        <when condition="@(context.Response.StatusCode == 401)">
            <set-header name="WWW-Authenticate" exists-action="override">
                <value>Bearer realm="<tenant-id>",error="invalid_token",error_description="Access Token missing or malformed.",authorization_uri="https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize",client_id="<client-id>"</value>
            </set-header>
        </when>
    </choose>
    <base />
</on-error>

fiddler中查看HTTP请求时,对login.microsoft.com的请求实际上会检索一个令牌。这是响应的主体:

{
    "token_type": "Bearer","scope": "some-scope user_impersonation","expires_in": "3599","ext_expires_in": "3599","expires_on": "1600932873","not_before": "1600928973","resource": "https://api-management-host","access_token": "<access-token>","refresh_token": "<refresh-token>","id_token": "<id-token>"
}

但是以下对API管理的请求不包含令牌-授权标头仅包含关键字Bearer:

Authorization: Bearer

任何有这种情况经验的人-或可以帮助我解决此问题?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。