12

I have added Sharepoint reference in my project. Even after adding reference, it is showing:

SharePointOnlineCredentials Missing or not found.

Can anyone suggest a solution?

shanabus
  • 12,989
  • 6
  • 52
  • 78
D.Daniel
  • 121
  • 1
  • 1
  • 3
  • 1
    Added tags relevant to the post – shanabus Jun 05 '17 at 15:16
  • 8
    If it's 2022 and you're using the Microsoft.SharepointOnline.CSOM package and find `SharePointOnlineCredentials` isn't found, it's been removed. See this [explanation](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard#using-modern-authentication-with-csom-for-net-standard) from the docs – Aaron Feb 09 '22 at 02:35

5 Answers5

16

Add this package "Microsoft.Sharepoint.Client.Online.CSOM"

BSAMEI
  • 201
  • 2
  • 5
13

I faced the same issue

It was due to the reason that I did not install the Microsoft.SharePoint.Client.Runtime package in the NuGet

enter image description here

Make sure that both the NuGet packages are installed in the solution

Vignesh Subramanian
  • 7,161
  • 14
  • 87
  • 150
3
  1. Right click on the project Click on Add Reference
  2. In the Assemblies, select Extensions Make sure that you have check both, Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime
  3. Add using Microsoft.SharePoint.Client; in your references
Vignesh Subramanian
  • 7,161
  • 14
  • 87
  • 150
1

Even having SharePoint references if you are not targeting .NET Framework, the error occurs because the SharePointOnlineCredentials class is not present in CSOM for .NET Standard.

You can see the explanation here (as @Aaron noticed): https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard#using-modern-authentication-with-csom-for-net-standard.

Using user/password based authentication, implemented via the SharePointOnlineCredentials class, is a common approach for developers using CSOM for .NET Framework. In CSOM for .NET Standard this isn't possible anymore, it's up to the developer using CSOM for .NET Standard to obtain an OAuth access token and use that when making calls to SharePoint Online.

0

Its possible that you are missing a reference to another required assembly. Check this out - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.sharepointonlinecredentials.aspx.

If that doesn't solve it, check to be sure that you are using the correct SDK/runtime versions for the Sharepoint version you are trying to deploy for.

shanabus
  • 12,989
  • 6
  • 52
  • 78