Get current logged user in Excel office-js add-in

I would like to add to my Excel add-in a mechanism to keep track of the last user who performed certain action and the date it was performed. Is it possible to get information about the user currently logged to Excel from the add-in?

Thanks!


As luck would have it, single sign-on (SSO) was released in developer preview the day before you posted your question. As part of the system, your add-in gets a token from the Office host application that contains a "preferred_username" property. The value of the property is the email of the user logged into Office.

There is an overview at Enable single sign-on for Office add-ins (preview).

There are two samples:

Office-Add-in-ASPNET-SSO

Office-Add-in-Nodejs-SSO

In both samples, the add-in also uses the token received from Office host to get an access token to Microsoft Graph, but your add-in doesn't have to take that extra step.

I don't know of any way of getting the user identity without using SSO.


From the tags, it looks you are talking about javascript addins (office 365). Unfortunately (AFAIK) it is not currently possible to get user information in javascript addins.

Probably your question is more or less a duplicate of this one: How to get username, email address, filename from task pane app