Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Office.context.mailbox.getCallbackTokenAsync on a shared mailbox fails #3748

Closed
kworksltd opened this issue Oct 12, 2023 · 27 comments
Closed
Assignees
Labels
Area: Outlook Issue related to Outlook add-ins Needs: author feedback Waiting for author (creator) of Issue to provide more info Status: fixed Fix is deployed and available to customer Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs

Comments

@kworksltd
Copy link

Using Office.context.mailbox.item.getSharedPropertiesAsync on a shared mailbox fails. This also happens when using the Script Lab for Outlook add-in, using the shared mailbox example. The expected behaviour when selecting the 'Run operation as delegate on selected message' returns nothing. Debugging the code reveals the getSharedPropertiesAsync call is returning an error: OSF.DDA.Error, Code 9018, "GenericTokenError". I expect the add-in to show the email's properties but instead it shows nothing.

I have tried this on the web client for Outlook on Windows 10 and the latest Outlook Client on Windows 10. I have checked all the settings on the shared mailbox to ensure I have the correct permissions and that it is visible in GAL

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Oct 12, 2023
@exextoc exextoc self-assigned this Oct 12, 2023
@exextoc exextoc added Needs: attention 👋 Waiting on Microsoft to provide feedback Area: Outlook Issue related to Outlook add-ins and removed Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP labels Oct 12, 2023
@exextoc
Copy link
Collaborator

exextoc commented Oct 12, 2023

Can you share the code snippet you are using

@exextoc exextoc added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Oct 12, 2023
@kworksltd
Copy link
Author

kworksltd commented Oct 12, 2023

This is the code taken from Script Lab for Outlook - the Perform operation as a delegate example.

$("#get").click(get);
$("#run-message").click(runOnMessage);
$("#run-appointment").click(runOnAppointment);

function get() {
  if (!Office.context.mailbox.item.getSharedPropertiesAsync) {
    console.error("Try this sample on an item from a shared folder.");
    return;
  }

  Office.context.mailbox.item.getSharedPropertiesAsync(function(result) {
    console.log(result.value);
  });
}

function runOnMessage() {
  if (!Office.context.mailbox.item.getSharedPropertiesAsync) {
    console.error("Try this sample on a message from a shared folder.");
    return;
  }

  Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
    if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") {
      Office.context.mailbox.item.getSharedPropertiesAsync(
        {
          // Pass auth token along.
          asyncContext: result.value
        },
        function(result2) {
          let sharedProperties = result2.value;
          let delegatePermissions = sharedProperties.delegatePermissions;

          // Determine if user has the appropriate permission to do the operation.
          if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) {
            var ewsId = Office.context.mailbox.item.itemId;
            var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0);
            let rest_url =
              sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/messages/" + restId;

            $.ajax({
              url: rest_url,
              dataType: "json",
              headers: { Authorization: "Bearer " + result2.asyncContext }
            })
              .done(function(response) {
                console.log(response);
              })
              .fail(function(error) {
                console.error(error);
              });
          }
        }
      );
    }
  });
}

function runOnAppointment() {
  if (!Office.context.mailbox.item.getSharedPropertiesAsync) {
    console.error("Try this sample on an appointment from a shared folder.");
    return;
  }

  Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
    if (result.status === Office.AsyncResultStatus.Succeeded && result.value !== "") {
      Office.context.mailbox.item.getSharedPropertiesAsync(
        {
          // Pass auth token along.
          asyncContext: result.value
        },
        function(result2) {
          let sharedProperties = result2.value;
          let delegatePermissions = sharedProperties.delegatePermissions;

          // Determine if user has the appropriate permission to do the operation.
          if ((delegatePermissions & Office.MailboxEnums.DelegatePermissions.Read) != 0) {
            var ewsId = Office.context.mailbox.item.itemId;
            var restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0);
            let rest_url =
              sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/events/" + restId;

            $.ajax({
              url: rest_url,
              dataType: "json",
              headers: { Authorization: "Bearer " + result2.asyncContext }
            })
              .done(function(response) {
                console.log(response);
              })
              .fail(function(error) {
                console.error(error);
              });
          }
        }
      );
    }
  });
}

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Oct 12, 2023
@exextoc
Copy link
Collaborator

exextoc commented Oct 12, 2023

Can you check if getCallbackTokenAsync api alone returns the token as expected for your account?

@exextoc exextoc added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Oct 12, 2023
@kworksltd
Copy link
Author

kworksltd commented Oct 12, 2023 via email

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Oct 12, 2023
@exextoc
Copy link
Collaborator

exextoc commented Oct 17, 2023

@kworksltd The error mentioned above is related to token API and not specific to getSharedPropertiesAsync
Could you please confirm if getCallbackTokenAsync api is working in the shared account by running below code?
Sample code:
Office.context.mailbox.getCallbackTokenAsync(
function (asyncResult)
{
console.log(JSON.stringify(asyncResult));
}
);

@exextoc exextoc added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Oct 17, 2023
@kworksltd
Copy link
Author

It is the getCallbackTokenAsync call (on the shared folder - works fine on the non-shared folder) that is returning the error. Please see the attached screenshot for the code and response in a debug window for Edge. The console window at the bottom shows the error. Although this is my code, I get the same response from the Script Lab sample I originally posted.

Screenshot 2023-10-17 at 13 13 09

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Oct 17, 2023
@exextoc
Copy link
Collaborator

exextoc commented Oct 17, 2023

Thanks for confirming. Has this been working previously, and have you only started receiving the error recently?

@exextoc exextoc added Needs: author feedback Waiting for author (creator) of Issue to provide more info Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Oct 17, 2023
@kworksltd
Copy link
Author

kworksltd commented Oct 17, 2023 via email

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Oct 17, 2023
@sahanar28
Copy link

sahanar28 commented Dec 11, 2023

MicrosoftTeams-image (13) Hi, @exextoc Even I am facing the same issue with Using Office.context.mailbox.getCallbackTokenAsync on a shared mailbox with the exact same error message and error code. I have already raised a github ticket for it. Is this issue fixed or when can we expect it be fixed?

@kworksltd
Copy link
Author

@kworksltd - Some fixes related to shared mailbox went in recently and changes are rolled out to prod. Can you please try again and check if you are still facing the issue?

I have tested this again today and I am still getting the same error response when using the shared inbox. is there a sample add-in you can provide to test this outside of our own code? Outlook Script-Lab that I had previously used to test this is now having its own problem (already reported).

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Dec 11, 2023
@exextoc
Copy link
Collaborator

exextoc commented Dec 12, 2023

@kworksltd Could you please confirm which Extension point is being used by your Add-in here?

@exextoc exextoc added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Dec 12, 2023
@kworksltd
Copy link
Author

The Extension point in my add-in is MessageReadCommandSurface

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Dec 12, 2023
@exextoc
Copy link
Collaborator

exextoc commented Dec 28, 2023

Thanks for reporting this issue regarding shared mailbox. It has been put on our backlog. We unfortunately have no timelines to share at this point
 
Internal tracking id: Office: 4023303

@exextoc exextoc removed the Needs: attention 👋 Waiting on Microsoft to provide feedback label Jan 2, 2024
@sajalsoni6
Copy link

@exextoc i'm still facing this issue. when will it be fixed?

@ingin97
Copy link

ingin97 commented Jan 23, 2024

@exextoc We are also facing this issue getting GenericTokenError (code 9018) when trying to obtain EWS or REST tokens for a shared mailbox, added as a shared folder.

@parlato-vooma
Copy link

@exextoc we're facing the same issue; getting a GenericTokenError (code 9018) when trying to fetch an access token. Code below; we're using https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js. This did appear to work for some time for us, and recently broke (within the last week, maybe). I don't think the users facing this issue are using a shared inbox, however - I'm not entirely sure what that means.

const getAccessToken = async () => {
  return new Promise<string>((resolve, reject) => {
    Office.context.mailbox.getCallbackTokenAsync(
      { isRest: true },
      function (result) {
        if (result.status === Office.AsyncResultStatus.Succeeded) {
          resolve(result.value);
        } else {
          reject(result.error);
        }
      }
    );
  });
};

@ajays-msft
Copy link

@kworksltd , @ingin97 -The shared mailbox token issue is now resolved. Fix is available in prod.

@ajays-msft ajays-msft added Needs: author feedback Waiting for author (creator) of Issue to provide more info Status: fixed Fix is deployed and available to customer and removed Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown labels Feb 25, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Status: no recent activity Issue or PR is stale (no recent activity) label Feb 29, 2024
@kworksltd
Copy link
Author

I can confirm that this is now working without presenting the error as originally submitted. I am therefore happy to mark this as closed.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Status: no recent activity Issue or PR is stale (no recent activity) Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Feb 29, 2024
@kdeshpande-methodcrm
Copy link

We are still facing the same issue. Do we know how this can be fixed? Or was there an update from Microsoft that we missed?

@mmanjaree-msft
Copy link

@kdeshpande-methodcrm Can you please open a separate issue and add repro steps and video/screenshot there

@exextoc exextoc added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Jun 26, 2024
@kdeshpande-methodcrm
Copy link

@mmanjaree-msft My colleague has opened an issue here : #4583
As for the reproduction steps, the comment - #4583 (comment) has an example to demonstrate the same issue we are facing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Outlook Issue related to Outlook add-ins Needs: author feedback Waiting for author (creator) of Issue to provide more info Status: fixed Fix is deployed and available to customer Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs
Projects
None yet
Development

No branches or pull requests

10 participants