I’m building an Excel Js add-in taskpane that provides basic features for free and advanced features for licensed users. For that, I need to know who the current user is to look up if they have a license. I can get the current user with SSO and getAccessToken to enable/disable the advanced features and that works well.
But in Excel, the user can switch between multiple accounts using the dropdown in the window title bar and I find that whenever I call getAccessToken, I’m always given the account they first opened Excel with, not the one they currently have selected. Furthermore, I really should be changing my UI when they switch accounts (e.g. if one account is licensed and the other isn’t), so I need an Excel application event to tell me that – I don’t see one mentioned in the Excel or Office object model documentation.
To test this, I had a button that calls getAccessToken, decodes the jwt and displays the user name. I changed the logged in account and clicked the button again. I expected the jwt to contain the new account details but it gave me the original one again.