no support for OfficeRuntime.auth.getAccessToken in Outlook add-ins but in Excel yes?

Wladimir Kirjanovs 0 Reputation points
2024-10-05T10:52:02.8766667+00:00

The Short Summary: Why does Office.auth.getAccessToken or OfficeRuntime.auth.getAccessToken works on Excel but not on Outlook. And why even though my Outlook version support the Idenitity API it show the message he identity API is not supported for this add-in.","code":13000

https://learn.microsoft.com/en-us/javascript/api/office/office.auth?view=common-js-preview

if I hardcode the const apiToken and const graphToken(see the commit above) it seems to work well so the problem lies in the getAccessToken function. Why does it work in excel but not in outlook?

Longer context: I forked this repo and tried to transform it to an outlook addin: https://github.com/microsoftgraph/msgraph-sample-office-addin

I am working on an Outlook add-in and encountered an issue with the OfficeRuntime.auth.getAccessToken method. The error message I received is:

getAccessToken error: {"name":"API Not Supported","message":"The identity API is not supported for this add-in.","code":13000}

even though the same code, the same api to allow the permissions does work as an excel addin.

Additionally, the backend error indicates that the token being sent to the server is undefined or invalid:

Verify error: {"name":"JsonWebTokenError","message":"jwt must be provided"}

I have made some changes to the manifest and taskpane.js to make it work in Outlook instead of Excel. However, I am still facing the issue. Here are the relevant code snippets:

Manifest changes(please scroll down to manifest.xml: https://github.com/microsoftgraph/msgraph-sample-office-addin/compare/main...Wladefant:msgraph-sample-office-addin:change-to-outlook-addin#diff-9699a53b6e95f11dec0062ed9cd8dba13ee841339ddc5b586b1fab11b83a6552L10-R10 taskpane.js changes: https://github.com/microsoftgraph/msgraph-sample-office-addin/compare/main...Wladefant:msgraph-sample-office-addin:change-to-outlook-addin#diff-9699a53b6e95f11dec0062ed9cd8dba13ee841339ddc5b586b1fab11b83a6552L10-R10

if I hardcode the const apiToken and const graphToken(see the commit above) it seems to work well so the problem lies in the getAccessToken function. Why does it work in excel but not in outlook?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
990 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.