This SharePoint csom tutorial, we will discuss how to fix an error The type or namespace SharePointOnlineCredentials could not be found which comes when we create a console application for SharePoint online Office 365 sites (sharepointonlinecredentials not found).
Recently I have created a console application for SharePoint online but when I am using the below code to pass the credentials to connect to SharePoint online site it gave the below error.
clientContext.AuthenticationMode = ClientAuthenticationMode.Default; clientContext.Credentials = new SharePointOnlineCredentials(GetSPOAccountName(), GetSPOSecureStringPassword());
The error comes as:
The type or namespace SharePointOnlineCredentials could not be found (are you missing a using directive or an assembly reference?). It looks like below:
In that console application, I have added the Microsoft.SharePoint.Client.dll (version: v14.0.4762.1000) from the NuGet package.
To resolve the issue, I have added the “Microsoft.Sharepoint.Client.Online.CSOM” from NuGet itself. You can find like below:
After this, the error (sharepointonlinecredentials not found) will not come.
You may like following SharePoint csom tutorials:
- Content type Examples using CSOM in SharePoint Online/2013/2016
- Get all lists and document libraries programmatically using CSOM in SharePoint Online
- Copy list items from one site collection to another programmatically using CSOM in SharePoint Online
- Add items from CSV file to SharePoint Online List using PowerShell in CSOM
- How to Use CAML Query for Boolean field for SharePoint 2013/2016/Online Object Model CSOM
- Create an index in SharePoint Online list using CSOM
This SharePoint tutorial helps us to solve error The type or namespace SharePointOnlineCredentials could not be found.
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com