using (ClientContext clientContext = new ClientContext("https://company.sharepoint.com/mysite"))
{
string password = pass;
string userName = [email protected];
SecureString secureString = new SecureString();
password.ToList().ForEach(secureString.AppendChar);
clientContext.Credentials = new SharePointOnlineCredentials(userName, secureString);
Web web = clientContext.Web;
clientContext.Load(web.Webs, we => we.Include(w => w.Url, w => w.Title));
clientContext.ExecuteQuery();
WebCollection site = web.Webs;
foreach (Web w in site)
{
Console.WriteLine(w.Title);
Console.WriteLine(w.Url);
}
}
The account I use has Visitor Read permission in mysite, when I run the above code, it throws the following error:
Access denied. You do not have permission to perform this action or access this resource.
However, if I any browser to open that site, I have no problem viewing the content and its sub-sites.
So, what permission do I need for this account to make my code works?