0

I'm creating an add-in for Excel. This add-in has to implement the single sign-on in Entra ID in order to call a protected API behind an Azure API Management.

I found a code in the Microsoft documentation and created a repo on GitHub. This add-in written in JavaScript is a boilerplate with the authentication in the Azure Entra ID.

What I can't find is how I can get the user token in order to call my APIs. For example, in the file taskpane.js I change this function

export async function run() {
  getUserProfile(writeDataToOfficeDocument);

  let userTokenEncoded = await Office.auth.getAccessToken();
  console.log(userTokenEncoded);
}

but no luck. So, I tried to change the function writeDataToOfficeDocument by adding those lines before the end

let userTokenEncoded = Office.auth.getAccessToken().result;
const rangeAddress2 = `C2:C2`;
const range2 = sheet.getRange(rangeAddress2);
range2.values = userTokenEncoded;
range2.format.autofitColumns();

return context. Sync();

but again I don't see any token.

0