Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 734
Mario Solís Avatar asked May 05 '17 20:05

Mario Solís


2 Answers

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.

like image 83
Rick Kirkham Avatar answered Nov 11 '22 02:11

Rick Kirkham


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

like image 1
Nikolay Avatar answered Nov 11 '22 00:11

Nikolay