问题描述
在我们的组织中,有些人使用Excel来访问我们的API。我们希望这些API通过API管理公开,并使用Azure Active Directory进行身份验证。
在excel中,可以通过使用“组织帐户”来实现,但是目前我收到消息“我们无法使用提供的凭据进行身份验证。请重试”。
我已遵循此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 (将#修改为@)