带有 WebApplicationInfo 的 OfficeJS 清单类型 MailApp 在 VS 2022 中出现部署错误

问题描述 投票:0回答:1

我正在使用 VS 2022,我正在尝试使用 Office 加载项实施 SSO,但是一旦我添加

<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1"
xsi:type="VersionOverridesV1_1">
    <WebApplicationInfo>
      <Id>guid</Id>
      <Resource>api://localhost:3000//guid</Resource>
      <Scopes>
        <Scope>Files.Read</Scope>
        <Scope>profile</Scope>
        <Scope>openid</Scope>
     </Scopes>
   </WebApplicationInfo>
<VersionOverrides>

我在调试期间收到错误弹出窗口。我在输出中看不到任何问题。

没有上面的部分,加载项正在构建,我可以在调试中运行。

我还需要补充什么吗?

我正在尝试获取访问令牌,目前的响应是:

The identity API is not supported for this add-in.

async function getUserData() {
    try {
        let userTokenEncoded = await OfficeRuntime.auth.getAccessToken();
        let userToken = jwt_decode(userTokenEncoded); // Using the https://www.npmjs.com/package/jwt-decode library.
        console.log(userToken.name); // user name
        console.log(userToken.preferred_username); // email
        console.log(userToken.oid); // user id     
    }
    catch (exception) {
        console.log(exception);
        if (exception.code === 13003) {
            // SSO is not supported for domain user accounts, only
            // Microsoft 365 Education or work account, or a Microsoft account.
            popup.showNotification("test");
        }
        if (exception.code === 13000) {
            // SSO is not supported for domain user accounts, only
            // Microsoft 365 Education or work account, or a Microsoft account.
            popup.showNotification(exception.message);
        }
        else {
            // Handle error
            popup.showNotification("test");
        }
    }
}
outlook single-sign-on office-js office-addins outlook-web-addins
1个回答
0
投票

确保您的加载项已注册到标识平台,有关详细信息,请参阅注册使用单点登录 (SSO) 的 Office 加载项与 Microsoft 标识平台

VSCode
中注册您的应用程序,然后自动配置加载项的清单文件,您可以使用以下命令:

"configure-sso": "office-addin-sso configure manifest.xml",

有关更多信息,请参阅 office-addin-sso 节点包。

注意,如果您的租户配置为需要双因素身份验证,则此命令将失败。在这种情况下,您需要按照创建使用单点登录的 Node.js Office 加载项 教程中的所有步骤手动完成 Azure 应用程序注册和 SSO 配置步骤。

© www.soinside.com 2019 - 2024. All rights reserved.