OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
677 stars 95 forks source link

[Outlook add-in] getCallbackTokenAsync failing to get Token #4626

Closed aelhennawy closed 3 months ago

aelhennawy commented 3 months ago

Provide required information needed to triage your issue

I'm developing an Outook add-in using:

In my local development currently i'm not able to get the Token using

Office.context.mailbox.getCallbackTokenAsync({isRest: true}, async (result) => {
console.log(result)
})

This result in this error on Mac platform Screenshot2024_06_25_135210

And on Windows platform i get this error 9784E131-567B-403A-B9D5-953CED862FB2

This is my manifest.xml file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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" xsi:type="MailApp">
  <Version>1.0.0.0</Version>
  <ProviderName>Demo</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Demo"/>
  <Description DefaultValue="Demo."/>
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-80.png"/>
  <SupportUrl DefaultValue="https://localhost:3000"/>

  <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/taskpane.html"/>
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>
  <Permissions>ReadWriteMailbox</Permissions>
  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/>
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.3">
        <bt:Set Name="Mailbox"/>
      </bt:Sets>
    </Requirements>
    <Hosts>
      <Host xsi:type="MailHost">
        <DesktopFormFactor>
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id="msgReadGroup">
                <Label resid="GroupLabel"/>
                <Control xsi:type="Button" id="msgReadOpenPaneButton">
                  <Label resid="TaskpaneButton.Label"/>
                  <Supertip>
                    <Title resid="TaskpaneButton.Label"/>
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="Taskpane.Url"/>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="GroupLabel" DefaultValue="Anti Phishing"/>
        <bt:String id="TaskpaneButton.Label" DefaultValue="Phishing Risk"/>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Analyze phising risk level"/>
      </bt:LongStrings>
    </Resources>

    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
      <Requirements>
        <bt:Sets DefaultMinVersion="1.3">
          <bt:Set Name="Mailbox"/>
        </bt:Sets>
      </Requirements>
      <Hosts>
        <Host xsi:type="MailHost">
          <DesktopFormFactor>
            <ExtensionPoint xsi:type="MessageReadCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="msgReadGroup">
                  <Label resid="GroupLabel"/>
                  <Control xsi:type="Button" id="msgReadOpenPaneButton">
                    <Label resid="TaskpaneButton.Label"/>
                    <Supertip>
                      <Title resid="TaskpaneButton.Label"/>
                      <Description resid="TaskpaneButton.Tooltip"/>
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16"/>
                      <bt:Image size="32" resid="Icon.32x32"/>
                      <bt:Image size="80" resid="Icon.80x80"/>
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url"/>
                      <SupportsPinning>true</SupportsPinning>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>
          </DesktopFormFactor>
          <MobileFormFactor>
            <ExtensionPoint xsi:type="MobileMessageReadCommandSurface">
              <Group id="mobileMsgRead">
                <Label resid="GroupLabel"/>
                <Control xsi:type="MobileButton" id="msgReadOpenPaneButton">
                  <Label resid="TaskpaneButton.Label"/>
                  <Icon xsi:type="bt:MobileIconList">
                    <bt:Image size="25" scale="1" resid="Icon.16x16"/>
                    <bt:Image size="25" scale="2" resid="Icon.16x16"/>
                    <bt:Image size="25" scale="3" resid="Icon.16x16"/>

                    <bt:Image size="32" scale="1" resid="Icon.32x32"/>
                    <bt:Image size="32" scale="2" resid="Icon.32x32"/>
                    <bt:Image size="32" scale="3" resid="Icon.32x32"/>

                    <bt:Image size="48" scale="1" resid="Icon.32x32"/>
                    <bt:Image size="48" scale="2" resid="Icon.32x32"/>
                    <bt:Image size="48" scale="3" resid="Icon.32x32"/>
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="Taskpane.Url"/>
                  </Action>
                </Control>
              </Group>
            </ExtensionPoint>
          </MobileFormFactor>
        </Host>
      </Hosts>
      <Resources>
        <bt:Images>
          <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
          <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
          <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
        </bt:Images>
        <bt:Urls>
          <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="GroupLabel" DefaultValue="Anti Phishing"/>
          <bt:String id="TaskpaneButton.Label" DefaultValue="Phishing Risk"/>
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Analyze phising risk level"/>
        </bt:LongStrings>
      </Resources>
    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>

I've tried searching for solutions to these errors but haven't found anything useful. Could you please help me identify if I'm missing something or doing something wrong?

Your Environment

Swathy-Mothilal commented 3 months ago

@aelhennawy Would be happy to help. Unfortunately, we couldn't reproduce the issue. The manifest you've shared is locally hosted. Could you please provide a manifest that is hosted online so we can reproduce the issue?

aelhennawy commented 3 months ago

@Swathy-Mothilal Thanks for your reply. You can find the manifest through this url ""

Also in the console you can find a log message called "GET HEADERS" and below it the result of the Office.context.mailbox.getCallbackTokenAsync

Note: I don't know if this might help but I'm not subscribed to Microsoft 365.

Swathy-Mothilal commented 3 months ago

@aelhennawy Could you please clarify what type of account you have, as you mentioned you are not subscribed to Microsoft 365?

aelhennawy commented 3 months ago

@Swathy-Mothilal Yes i'm not subscribed. I have a normal outlook email without any subscriptions

Swathy-Mothilal commented 3 months ago

@aelhennawy Thanks for the confirmation. We don't support getCallbackTokenAsync for accounts that are not subscribed to M365.

aelhennawy commented 3 months ago

@Swathy-Mothilal Ok, thank you for the clarification.

Aniruddha-Shriwant commented 3 months ago

We don't support getCallbackTokenAsync for accounts that are not subscribed to M365.

@Swathy-Mothilal thanks for this info, is this documented somewhere? sorry couldn't find this info here: https://learn.microsoft.com/en-us/javascript/api/requirement-sets/outlook/preview-requirement-set/office.context.mailbox?view=common-js-preview#methods

Swathy-Mothilal commented 3 months ago

Yes, we will update the public documentation.