我想用 passport-azure-ad 保护 Web API 并使用 BearerStrategy。我遵循模块提供的示例并传递元数据和clientId,我总是得到401未经授权。
这是我的 passport-azure-ad 配置
{
identityMetadata: 'https://login.microsoftonline.com/<your_tenant_guid>/v2.0/.well-known/openid-configuration'
// Required
clientID: '<client ID>',
// Required.
// If you are using the common endpoint, you should either set `validateIssuer` to false, or provide a value for `issuer`.
validateIssuer: false,
// Required.
// Set to true if you use `function(req, token, done)` as the verify callback.
// Set to false if you use `function(req, token)` as the verify callback.
passReqToCallback: false,
// Optional. Default value is false.
// Set to true if you accept access_token whose `aud` claim contains multiple values.
allowMultiAudiencesInToken: false,
loggingLevel:'error',
};
}
我为授权请求标头提供了由 vue-msal 生成的访问令牌。
我还检查了访问令牌的签名也无效。
此外,我使用了 ID 令牌,但仍然 401 未经授权。
在门户 /AAD /App 注册中,我已经启用了两个隐式授权流程、<code>accessTokenAcceptedVersion: 2、在 API 权限中为我的订阅授予管理员同意
我还错过了什么?