When making the call to initialize multiple user personal sites, I'm receiving the following error back:

[ { "SchemaVersion":"","LibraryVersion":"16.0.7324.1200","ErrorInfo":{ "ErrorMessage":"Access denied. You do not have permission to perform this action or access this resource.","ErrorValue":null,"TraceCorrelationId":"03ab459e-7076-5000-c1a7-196f1fc54384","ErrorCode":-2147024891,"ErrorTypeName":"System.UnauthorizedAccessException" },"TraceCorrelationId":"03ab459e-7076-5000-c1a7-196f1fc54384" } ]

I'm following the example here: https://docs.microsoft.com/en-us/sharepoint/dev/general-development/what-s-new-for-developers-in-social-and-collaboration-features-in-sharepoint-201

Note: mySiteUrl is equal to https://{tenantName}.sharepoint.com, tenantName being the name of the tenant.

using (var ct = new ClientContext(mySiteRootUrl))
    var emails = xnl.ToList().Select(x => $"{XmlHelper.GetAttribute(x, "AccountName")}@{userDomain}").ToArray();

    var securePass = new SecureString();
    Array.ForEach(context.Password.ToCharArray(), c => securePass.AppendChar(c));

    var credentials = new SharePointOnlineCredentials($"{adminAccountName}@{userDomain}", securePass);

    ct.Credentials = credentials;

    var web = ct.Web;

    ProfileLoader loader = ProfileLoader.GetProfileLoader(ct);

    if (loader == null)
        throw new InvalidOperationException("Failed to get ProfileLoader");


My code above is pretty closely mapped to the code in the example. The user I'm logged in with is the Global Admin, but yet I get an Access Denied error. Any ideas?

Thanks in advance.

1 Answer 1


The issue ended up being the OneDrive license in Office 365 was flipped to "off" for this user. Since personal sites are linked with OneDrive, this caused the above error to be thrown.

To see the licenses, you must login as the Admin, go to the Admin panel in Office 365, and click Users. Click the affected user and make sure the proper licenses under his subscriptions are enabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.