1
votes

I'm a developer working on an add-in for Microsoft Outlook, and we've been encountering a login issue with some of our users.

In our code, one of the ways we validate users with our system is by comparing the email address retrieved from Office.js to the email address we have stored for them on the server.

We get the email address from Office.js using Office.context.mailbox.userProfile.emailAddress and match it to the email address from the ‘me’ endpoint (https://outlook.office365.com/api/v2.0/me) but these two don't always return the same address.

It seems that the mismatch might have something to do with when the user has a new primary alias or has switched to a new domain.

I have a few questions:

  • Is this the correct way to get the two email addresses?
  • When a user changes domains or aliases, is the change propagated to the front-end Office.js and the backend endpoint in different ways, such as different cache layers?
  • Is there another endpoint we can call to get the two addresses to always match?

Thank you!

1

1 Answers

2
votes

A user can have more than one email address. By the default, the /me endpoint only returns the primary email address. The rest are held in the proxyAddresses property.

You can ask /me to return the additional properties by adding it to a select clause like this:

/me?$select=proxyAddresses,displayName,id,jobTitle,mail,userPrincipalName