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

OfficeRuntime.auth.getAccessToken fails after a period of inactivity #5260

Open
ragnarstolsmark opened this issue Jan 10, 2025 · 4 comments
Open
Assignees
Labels
Area: Outlook Issue related to Outlook add-ins Needs: attention 👋 Waiting on Microsoft to provide feedback

Comments

@ragnarstolsmark
Copy link

Provide required information needed to triage your issue

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: Office on the web
  • Host [Excel, Word, PowerPoint, etc.]: Outlook
  • Office version number: OfficeOnline
  • Operating System: Windows
  • Browser (if using Office on the web): Edge 131.0.2903.112

Expected behavior

I expected the OfficeRuntime.auth.getAccessToken to return an access token. It has worked well until late december 2024 (approx. 26 december)

Current behavior

It returns error code 13006.

Steps to reproduce

  1. Call getAccessToken.
  2. Wait for more than 1 day.
  3. Call getAccessToken again.

Provide additional details

We handle error 13006 by using an MSAL popup. Subsequent calls to getAccessToken do not fail after the popup has successfully authenticated the user.

Context

The issue is degrading the user experience of customers using our Outlook add-in. It only affects Outlook online.

Useful logs

image
Screenshot of our application insights showing the trend for error code 13006.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Jan 10, 2025
Copy link

Here are some similar issues that might help you. Please check if they can solve your problem.


Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Solution 1:

Ensure that the add-in id has been added to the list of authorized applications. The id needs to be pre-authorized. Refer to the doc: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/register-sso-add-in-aad-v2

Reference:

Solution 2:

We had the same problem after the last Outlook Desktop update. When we added the Client Id from the error message as a pre-authorized client in the App registration (Expose an API) it worked again.

Reference:

@ragnarstolsmark
Copy link
Author

The similar issues are older than our new issue and they are not relevant to our problem.

@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 Similar-Issue Possible-Solution labels Jan 10, 2025
@exextoc exextoc self-assigned this Jan 10, 2025
@sivachandran-msft
Copy link

Hi @ragnarstolsmark , thanks for reporting and sharing the details. Could you please help us with below information to investigate it further:

  • Please share the code snippet you tried to access the getAccessToken
  • If you have sample addin where the issue is reproducible, please it with exextoc account
  • Please share us the scenario where this issue is observed.

@sivachandran-msft sivachandran-msft 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 Jan 16, 2025
@ragnarstolsmark
Copy link
Author

Here is our code that gets the accessToken:

async function getAccessTokenOfficeRuntime(): Promise<string> {
  // The getAccessToken api mutates the passed in object. So we have to destructure it every time we use it
  const parameters = {
    allowConsentPrompt: false,
    allowSignInPrompt: !isInEventContext(), //isInEventContext() returns true when the code is triggered by an outlook add-in event.
  };
  try {
    const accessToken = await OfficeRuntime.auth.getAccessToken({ ...parameters });
    return accessToken;
  } catch (error) {
    if (!shouldRetry(error)) {
      throw error;
    }
  }

  return new Promise((resolve, reject) => {
    setTimeout(() => {
      OfficeRuntime.auth
        .getAccessToken({ ...parameters })
        .then(resolve)
        .catch(reject);
    }, 300);
  });

We do not have a sample addin where the issue is reproducible.

The scenario is observed by our users who use our outlook add-in for inserting signatures into their e-mails. It seems to appear more often when the user has been inactive for some time, maybe it has something to do with a token that has expired?

@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 Jan 17, 2025
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: attention 👋 Waiting on Microsoft to provide feedback
Projects
None yet
Development

No branches or pull requests

3 participants