【问题标题】:How to Identify an Office 365 User Account from inside an Excel Add in如何从 Excel 加载项中识别 Office 365 用户帐户
【发布时间】:2016-05-06 11:49:45
【问题描述】:

我想了解是否有任何 API 可以帮助我们从我的 Excel 加载项 JavaScript 代码中找到 Office 365 用户帐户信息。 例如,假设拥有 Office 电子邮件帐户 abc@xyz.com 的用户启动 Excel,从 Office 商店下载我的加载项并使用它。 我想从我的应用程序中为下载/使用我的应用程序的各种用户捕获此用户信息。 办公应用程序中是否有 API 可以实现此目的?

【问题讨论】:

    标签: office-addins excel-addins office-js


    【解决方案1】:

    不,目前 Word/Excel/PowerPoint 中的 Office 加载项中没有 API 可以公开登录到 Office 客户端的人员的用户信息。

    在 Outlook 加载项中,您可以检索此信息。

    // Example: Allie Bellew
    console.log(Office.context.mailbox.userProfile.displayName);
    
    // Example: allieb@contoso.com
    console.log(Office.context.mailbox.userProfile.emailAddress);
    

    请参阅userProfile object documentation 了解更多信息。

    【讨论】:

    • 网址损坏,请修改
    【解决方案2】:

    补充道格的回复:虽然它不会公开用户的电子邮件地址,但如果您的应用位于 Office 商店中,您可以从授权令牌中获取用户的唯一标识符。请参阅https://msdn.microsoft.com/en-us/library/office/jj164035.aspx 了解更多信息。

    权利令牌响应 (https://msdn.microsoft.com/en-us/library/office/verificationsvc.verifyentitlementtokenresponse_members.aspx) 的 UserId 属性是购买者 ID。根据上述文档,“这是购买应用程序的人使用的 Microsoft 帐户的加密值”。

    希望这会有所帮助,

    ~ Michael Zlatkovsky,Office 可扩展性团队的开发人员,MSFT

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-19
      • 1970-01-01
      相关资源
      最近更新 更多