I'm currently trying to get the officeLocation field for users within our organization using the MS graph api. I'm using the following endpoint:
https://graph.microsoft.com/v1.0/users/[email protected]?$select=department,displayName,jobTitle,mail,officeLocation,usageLocation
However, officeLocation is coming back as null. Looking at the documentation, it seems as though I need the Read.All permission which is an admin level permission. Is there know other way to get the users office location without an admin permission?
I'm assuming you've requested the User.ReadBasic.All
scope. This will only provide your app access to a limited set of basic profile properties (displayName
, givenName
, surname
, mail
, photo
, and extensions
). As you've found, officeLocation
is not included in the basic profile property set.
In order to retrieve officeLocation
you'll need a minimum of User.Read.All
permission. As you noted, this requires that your application recieve Admin Consent before a normal user can consent to it themselves.
As a general rule of thumb, access to "other user's data" (any user other than the one who authenticated) requires a Tenant Admin to give their consent.