I'd like to be able to programmatically retrieve a user's name and manager using code similar to the following:
using (var clientContext = TokenHelper.GetClientContextWithAccessToken(hostWeb.ToString(), accessToken))
{
var peopleManager = new PeopleManager(clientContext);
var personProperties = peopleManager.GetPropertiesFor(loginName);
clientContext.Load(personProperties);
clientContext.ExecuteQuery();
property = personProperties.UserProfileProperties[requestedProperty].ToString();
return property;
}
On an app without the User Profiles (Social)
permission, I get an Access Denied on the ExecuteQuery()
. I assume you need the User Profiles (Social) | Read
permission on the app to be able to do this. I attempted to side-load an app with this permission on a dev site and was told I needed to be a Tenant Administrator which now has me doubting whether this permission is valid for a store-based app.
Is it possible to access user data such as PreferredName and Manager using the PeopleManager in an app on the SharePoint AppStore? If not, is it possible to access this data in a non-interactive fashion using Microsoft Graph?