Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在API管理上验证MSAL令牌?_C#_Azure Api Management_Msal - Fatal编程技术网

C# 如何在API管理上验证MSAL令牌?

C# 如何在API管理上验证MSAL令牌?,c#,azure-api-management,msal,C#,Azure Api Management,Msal,我有一个使用ADAL进行身份验证的桌面应用程序,该应用程序向API管理azure服务上的API发出请求。将代码迁移到使用MSAL后,API管理返回401,指出我的令牌无效。我看到的监视请求的唯一区别是ADAL向该端点发出请求/tenantID/oauth2/token和MSAL/tenantID/oauth2/v2.0/token 在API管理中,我有以下策略: <validate-jwt header-name="Authorization" failed-validation-

我有一个使用ADAL进行身份验证的桌面应用程序,该应用程序向API管理azure服务上的API发出请求。将代码迁移到使用MSAL后,API管理返回401,指出我的令牌无效。我看到的监视请求的唯一区别是ADAL向该端点发出请求
/tenantID/oauth2/token
和MSAL
/tenantID/oauth2/v2.0/token

在API管理中,我有以下策略:

    <validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid. AAD" require-expiration-time="false">
         <openid-config url="https://login.microsoftonline.com/tenantID/.well-known/openid-configuration" />
    </validate-jwt>

我试图将众所周知的url更改为v2.0端点,但得到了相同的错误。如何使用MSAL验证令牌?

在中的注释中,当将已知url更改为v2.0时,您可能需要使用
common
而不是
tenantID

<openid-config url="https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration" />

此外,请确保您已正确完成本节中的步骤10:

如果使用v2端点,请使用为后端应用程序创建的作用域 在默认范围字段中。另外,请确保为设置值 将属性设置为中的
2


我可以知道它是否有用吗?如果有帮助,请接受它作为答案,谢谢。