我目前正在尝试使用以下文档实施 Oauth2.0 来保护 API
https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-protect-backend-with-aad
目前使用 azure apim 提供的 DEMO CONFERENCE API 来测试实现。
目前在开发人员门户中的测试期间收到错误:
“消息”:“JWT 验证失败:声明值不匹配:aud=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxx..”
通过解码和匹配将传递的令牌与声明值进行比较。
我有如下的 jwt 令牌验证策略
<inbound>
<base />
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid." require-expiration-time="false" require-signed-tokens="false">
<openid-config url="https://login.microsoftonline.com/xxxxxxxxx-07c8-xxxxx-xxxx-xxxxxxxxx/.well-known/openid-configuration" />
<required-claims>
<claim name="aud" match="all" separator="-">
<value>xxxxxxxx-xxxxx-489e-a26e-xxxxxxxx</value>
</claim>
</required-claims>
</validate-jwt>
</inbound>