I managed to connect to out SharePoint instance with this code
using (var clientContext = new ClientContext(url))
{
var oWebsite = clientContext.Web;
clientContext.Load(oWebsite);
clientContext.Credentials = new SharePointOnlineCredentials(username, password);
clientContext.ExecuteQuery();
Console.WriteLine("Title: {0} Created: {1}", oWebsite.Title, oWebsite.Created);
}
Which seemed to work one or two times, but normally when I run it I get this error on the ExecuteQuery()
line:
The remote server returned an error: (429).
from this post I can see this error appears to be a "stop sending so many requests" warning, but is there way to stop this from happening? It's not like I'm doing anything which will put much strain on the server (simply connecting to SharePoint)