I am trying to insert items in SharePoint online list from c# console application using CSOM method, but every time it gives me only one error:

> 
> "The remote server returned an error: (401) Unauthorized."
>  Exception thrown: 'System.Net.WebException' in Microsoft.SharePoint.Client.dll 
> 
> 
> 

My question would be how can I authenticate to SharePoint online list from my C# console application?

I have checked my credentials, everything is correct still I am getting this unauthorized error.

Here is my code in c#:

[![Insert item in SharePoint online list code](https://i.stack.imgur.com/5wOHy.png)](https://i.stack.imgur.com/5wOHy.png)

Please do reply if anyone has any idea how to resolve this error!

Thanks,  

Shaily