I am trying to get favorite sites of a user from SharePoint Online using CSOM. I am creating a ClientContext first using an access token and then trying to get the favorite sites using below code:
try
{
ClientContext clientContext = this.GetSharePointClientContext(accessToken);
SocialFollowingManager followingManager = new SocialFollowingManager(clientContext);
// Get the count of sites that the current user is following.
ClientResult<int> followedSiteCount = followingManager.GetFollowedCount(SocialActorTypes.Sites);
// Get the sites that the current user is following.
ClientResult<SocialActor[]> followedSiteResult = followingManager.GetFollowed(SocialActorTypes.Sites);
// Get the information from the server.
clientContext.ExecuteQuery();
}
catch (Exception)
{
throw;
}
I am not able to find the root cause of this issue. Everything else seem to be working fine except getting favorite sites. Need help in resolving this issue.