none
Add-in error on PersonProperties loading RRS feed

  • Question

  • Hi,

    About a month ago, one of our clients reported an issue with a Provider-Hosted App we had developped last year.

    Basically, the App grabs information stored in custom Profile Properties we created, and the content of those fields are used to generate *.docx resumes.

    Since approximately the middle of march, the App crashes approximatively 80% of the time we try to use it, and the troubleshooting lead us to the method we use to retrieve the user's properties:

    SharePointContext spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
    using (ClientContext clientContext = spContext.CreateUserClientContextForSPHost())
    {
        Web web = clientContext.Web;
        clientContext.Load(web);
        clientContext.ExecuteQuery();
    
        try
        {
            PeopleManager peopleManager = new PeopleManager(clientContext);
            PersonProperties personProperties = peopleManager.GetPropertiesFor(loginName);
            clientContext.Load(personProperties);
            clientContext.ExecuteQuery();
    
            return personProperties;
        }
        catch (Exception ex)
        {
            Response.AppendToLog(ex.StackTrace);
            return null;
        }
    }

    The error message we were able to get was:

    You do not have permission to perform this action or access this resource.We tried to update the App permissions and give Full Control to the 3 scopes (Site Collection, News Feed (Social) & User Profiles (Social)) to no avail: we were still experiencing errors when we tried to generate resumes.

    Do you have an idea about what the problem would be?
    Thanks in advance.

    P.S.: If this is of any help, here is the same issue reported on the SharePoint PnP Github: https://github.com/SharePoint/PnP/issues/1619

    Tuesday, April 18, 2017 7:46 AM

All replies

  • Hi,

    Could you check below factors?

    Does the user profile code/logic works fine.(you could create a console app for test purpose)

     using (var clientContext = new ClientContext("https://xxx.sharepoint.com/sites/lee/"))
                {
                    string password = "pw";
                    SecureString sec_pass = new SecureString();
                    Array.ForEach(password.ToArray(), sec_pass.AppendChar);
                    sec_pass.MakeReadOnly();
                    clientContext.Credentials = new SharePointOnlineCredentials("user@xxx.onmicrosoft.com", sec_pass);
                    
                    var peopleManager = new PeopleManager(clientContext);
                    var properties = peopleManager.GetMyProperties();
                    clientContext.Load(properties, p => p.AccountName);
                    clientContext.ExecuteQuery();
                    var personProperties = peopleManager.GetPropertiesFor(properties.AccountName);
                    clientContext.Load(personProperties);
                    clientContext.ExecuteQuery(); // Access denied exception encounted here...
                    var ups= personProperties.UserProfileProperties;
                    Console.WriteLine(ups.Count);
                    Console.ReadKey();
    
                }

     

    Does the app ClientId exists in /_layouts/15/AppPrincipals.aspx.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, April 19, 2017 3:20 AM
  • Hi,

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

    You can mark the helpful post as answer to help other community members find the helpful information quickly.

    You can also share your own solution here and mark it as answer, and we can learn from each other.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, April 25, 2017 5:16 AM
  • Hi,

    I can confirm that the profile logic seems to work just fine (I ran several tests to be sure that it was not just "luck").

    I can also confirm that the app's ClientId exists in the AppPrincipals page.

    I'm still looking for a solution on my end, but thanks for your time!

    Thursday, May 4, 2017 7:31 AM
  • Hi,

    I’m not clear about what you mean by “(I ran several tests to be sure that it was not just "luck"”.

    One more point is that make sure your add-in client secret not got expired as it will expire after one year.

    You could follow below guideline to check and update it if expired.

    https://dev.office.com/sharepoint/docs/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, May 12, 2017 1:18 PM