MSAL idToken 没有 upn、配置文件或电子邮件数据?在 idToken 中需要它以进行 passport-azure-ad 授权

MSAL idToken does not have upn, profile or email data? need it in idToken for passport-azure-ad authorization

我有一个使用官方 msal 包的 angular8 应用程序 (not the one for angular, the main one) on the backend I'm authorizing using passport-azure-ad (official microsoft package)

我需要在 IdToken 中包含用户的电子邮件地址,因为我无法使用不记名策略针对访问令牌进行验证。我需要一些方法来通过 UPN 或直接获取该电子邮件地址。

我在不同的 AD 组下尝试了 4 个不同的帐户,到目前为止只有 1 个 AD 组实际上在 idToken 中显示了 'email' 或 'upn' 字段。

Permissions configured in the app screenshot.

登录请求选项:

  private loginRequest: Msal.AuthenticationParameters = {
    scopes: ['user.read', 'email', 'profile', 'openid'],
    extraScopesToConsent: ['email']
  };

我尝试了我能想到的任何变体,我尝试让它们以大写字母(电子邮件,User.Read)开头,就像屏幕截图中那样,我尝试将它们围绕范围和 extraScopesToConsent 进行交换,我'我试过将 'upn' 放在任何地方,但没有成功。

是否可以:

A:以某种方式在令牌中获取该数据 B:获取另一个令牌,我可以将其验证为 'bearer token' 我的后端具有该数据?

我最终从前端发送了请求正文中的电子邮件,然后更新了我的通行证策略以使用请求对象。