首页 文章

OfficeJS Manifest类型MailApp - 无法使用WebApplicationInfo

提问于
浏览
1

我按照doc的步骤进行了操作 . 该应用程序已注册,我已获得我想在WebApplicationInfo中使用的guid来获取OAuth令牌 . 不幸的是使用office addin manifest验证器(npm -i -g validate-office-addin)我收到错误

XML模式冲突:您的清单不符合Office加载项清单的当前XML模式定义集 . (链接:https://aka.ms/add-in-manifest-schema-violation) - 详细信息:名称空间“http://schemas.microsoft.com/office/appforoffice/1.1”中的“OfficeApp”元素无效命名空间“http://schemas.microsoft.com/office/mailappversionoverrides/1.1”中的子元素“VersionOverrides” . 预期可能元素的列表:名称空间“http://schemas.microsoft.com/office/mailappversionoverrides”中的“VersionOverrides”以及名称空间“http://www.w3.org/2000/09/xmldsig#”中的任何元素” .

的Manifest.xml:

<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp 
          xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" 
          xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.1"
          xsi:type="MailApp">

  <!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->

  <!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
  <Id>c64ded7d-29e6-4083-8afa-351c7a630668</Id>

  <!--Version. Updates from the store only get triggered if there is a version change. -->
  <Version>1.0.0.0</Version>
  <ProviderName>An Tran</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
  <DisplayName DefaultValue="MyMeetings" />
  <Description DefaultValue="Find a room"/>

  <!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png" /> 
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/hi-res-icon.png"/>
  <SupportUrl DefaultValue="https://contoso.com/support " />

  <!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
  <AppDomains>
    <AppDomain>AppDomain1</AppDomain>
    <AppDomain>AppDomain2</AppDomain>
    <AppDomain>AppDomain3</AppDomain>
  </AppDomains>

  <Hosts>
    <Host Name="Mailbox" />
  </Hosts>
  <Requirements>
    <Sets>
      <Set Name="Mailbox" MinVersion="1.1" />
    </Sets>
  </Requirements>
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://localhost:3000/index.html"/>
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
     <Form xsi:type="ItemEdit">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://localhost:3000/index.html"/>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <Permissions>ReadWriteItem</Permissions>

  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit" />
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Read" />
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
  <!-- <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1"> -->

    <Hosts>
      <Host xsi:type="MailHost">

        <DesktopFormFactor>
          <!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). -->
          <FunctionFile resid="functionFile" />

            <ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
              <OfficeTab id="TabDefault">
                  <Group id="apptComposeDemoGroup">
                      <Label resid="groupLabel" />
                      <!-- Function (UI-less) button -->
                      <Control xsi:type="Button" id="apptComposeFunctionButton">
                          <Label resid="funcComposeButtonLabel" />
                          <Supertip>
                              <Title resid="funcComposeSuperTipTitle" />
                              <Description resid="funcComposeSuperTipDescription" />
                          </Supertip>
                          <Icon>
                              <bt:Image size="16" resid="icon16" />
                              <bt:Image size="32" resid="icon32" />
                              <bt:Image size="80" resid="icon80" />
                          </Icon>
                          <Action xsi:type="ExecuteFunction">
                            <FunctionName>run</FunctionName>
                          </Action>
                      </Control>             
                  </Group>
              </OfficeTab>
          </ExtensionPoint>
          <!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee -->
        </DesktopFormFactor>
      </Host>
    </Hosts>

    <Resources>
      <bt:Images>
        <bt:Image id="icon16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
        <bt:Image id="icon32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
        <bt:Image id="icon80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="functionFile" DefaultValue="https://localhost:3000/function-file/function-file.html"/>
        <bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:3000/function-file/function-file.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="groupLabel" DefaultValue="MyMeetings Group"/>
        <bt:String id="customTabLabel"  DefaultValue="My Add-in Tab"/>
        <bt:String id="funcComposeSuperTipTitle" DefaultValue="Find a room!"/>
        <bt:String id="funcComposeButtonLabel" DefaultValue="MyMeetings!"/>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="funcComposeSuperTipDescription" DefaultValue="Find a most suitable room with MyMeetings."/>
      </bt:LongStrings>
    </Resources>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
    <WebApplicationInfo>
      <Id>c64ded7d-29e6-4083-8afa-351c7a630668</Id>
      <Resource>api://localhost:3000/c64ded7d-29e6-4083-8afa-351c7a630668</Resource>
      <Scopes>
        <Scope>files.read.all</Scope>
        <Scope>profile</Scope>   
      </Scopes>
    </WebApplicationInfo>
    </VersionOverrides>
  </VersionOverrides>

</OfficeApp>

附:我的目标是让下面的代码工作,为此我相信我必须使用WebApplicationInfo元素的清单文件 .

Office.context.auth.getAccessTokenAsync(function(result) {
   if (result.status === "succeeded") {
     var token = result.value.accessToken;
   } else {
     console.log("Error obtaining token", result.error);
   }
 });

1 回答

  • 1

    我不太熟悉Office加载项中的SSO,但以下文档包含的信息可能有助于您解决已描述的问题:

    特别是,我注意到文档中的以下信息可能有助于解决您所描述的问题:

    • For an Outlook add-inWebApplicationInfo 元素应出现在 <VersionOverrides ... xsi:type="VersionOverridesV1_1"> 部分的末尾 . (您发布的代码将其包含在 <VersionOverrides ... xsi:type="VersionOverridesV1_0"> 部分的末尾 . )

    • WebApplicationInfo 元素中,应该 not 是围绕 Id 元素或 Resource 元素中的ID值的花括号( {} ) . (您发布的代码在两个位置的ID值周围都包含大括号 . )reference docs包含 WebApplicationInfo 元素的示例 .

    • 当您使用 WebApplicationInfo 元素注释掉 getAccessTokenAsync 时收到错误( 13000 - Identity API not supported )的事实是按设计/预期(在文档中为described here) .


    Update (来自Marc LaFleur的其他信息):

    根据Marc在下面的注释中链接到的doc中的信息,您可以尝试在v1.0的 VersionOverrides 元素中嵌套_1实现v1.1的 VersionOverrides 元素(其中包含 WebApplicationInfo 元素),正如文档所述 .

相关问题