【问题标题】:node-outlook doesn't let me grant permissions to a different emailnode-outlook 不允许我向其他电子邮件授予权限
【发布时间】:2018-01-24 22:58:01
【问题描述】:

所以我构建了一个简单的应用程序,并尝试将 Outlook 的 API 集成到其中。我创建了一个 Outlook 帐户,注册了一个应用程序并使用密钥设置了所有内容。当它把我带到 Azure 登录页面时,我使用我注册应用程序的帐户登录,并且我能够返回帐户日历的 JSON 数据。

但是,当我尝试另一个 Outlook 帐户时,我遇到了问题:

getUserEmail returned an error: [object Object]

这是以下函数:

// Function to retrieve email in order to find user
async function getUserEmail(token) {
  // Create a Graph client
  const client = microsoftGraph.Client.init({
    authProvider: done => {
      // First parameter is is error handling if no token is retrieved
      // If token is available then return the token
      done(null, token);
    }
  });

  const res = await client.api('/me').get();

  // Outlook.com users have userPrincipalName instead of a mail attribute
  return res.mail ? res.mail : res.userPrincipalName;
}

解决错误本身会返回此消息:

all the offeractions provided in the property bag cannot be validated for the token

我现在真的很困惑,为什么我只能使用我注册应用程序的帐户访问数据?我是否需要更改应用注册中的其他内容?

【问题讨论】:

  • 确保您在登录期间提供了正确的权限范围。

标签: javascript azure email outlook-restapi


【解决方案1】:

其他用户是否来自您自己的组织?如果没有,xyz 域公司的 IT 管理员 (email@xyz.onmicrosoft.com) 必须代表整个公司给予同意,以便该公司的用户能够使用您的应用程序。这是一个非常好的流程示例:

https://blog.mastykarz.nl/implementing-admin-consent-multitenant-office-365-applications-implicit-oauth-flow/

【讨论】:

    猜你喜欢
    • 2016-09-28
    • 2014-07-04
    • 2018-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 2013-09-14
    相关资源
    最近更新 更多