none
SharePointOnlineCredentials could not be found RRS feed

  • Question

  • Hello,

    I have problem with SharePointOnlineCredentials function. Console says that it could not be found. And I really don't know why because I'm looking on the internet for few days and just copy code for test. And it is always problem with SharePointOnlineCredentials. I have using using Microsoft.SharePoint.Client and I also installed package with nuGet... I don't know what should I do.


    using Microsoft.SharePoint.Client;
    using System;
    using System.Security;

    namespace ConnectingToO365
    {
        public class Program
        {
            static void Main(string[] args)
            {
                string siteURL = "sth";
                string userName = "sth.onmicrosoft.com";
                string password = "sth";

                //Create the client context object and set the credentials  
                ClientContext clientContext = new ClientContext(siteURL);
                SecureString securePassword = new SecureString();
                foreach (char c in password.ToCharArray()) securePassword.AppendChar(c);
                clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
                //Load the web  
                Web web = clientContext.Web;
                clientContext.Load(web);
                clientContext.ExecuteQuery();
                Console.WriteLine(web.Title);
                Console.ReadKey();
            } 
        }  
    }

    If anyone can help me, I will be very thankfull.

    Thank you and be safe.

    Tuesday, October 6, 2020 8:30 AM

Answers

  • Thank you for your answer

    It was my fault. I was using .NET standard instead of .NET framework.

    Better check documentation next time :)

    (https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard)

    Benjamin



    • Marked as answer by dataBeni Wednesday, October 7, 2020 10:22 AM
    • Edited by dataBeni Wednesday, October 7, 2020 10:22 AM
    Tuesday, October 6, 2020 6:22 PM

All replies

  • Hi 

    Try installing the Microsoft.SharePoint.Client.Runtime package from NuGet and see if it works.

    Cheers

    Reshmee

    Tuesday, October 6, 2020 8:35 AM
  • Thank you for your answer

    It was my fault. I was using .NET standard instead of .NET framework.

    Better check documentation next time :)

    (https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard)

    Benjamin



    • Marked as answer by dataBeni Wednesday, October 7, 2020 10:22 AM
    • Edited by dataBeni Wednesday, October 7, 2020 10:22 AM
    Tuesday, October 6, 2020 6:22 PM
  • Hi, dataBeni,

    Non-SPMT(SharePoint Migration Tool) has transitioned to Microsoft Q&A for support, please visit the "Microsoft 365 on Q&A" site within Microsoft Q&A to post all non-SPMT questions regarding SharePoint.

    All SPMT(SharePoint Migration Tool) questions can continue to be asked in this TechNet forum.

    Best Regards

    Jerry


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Friday, October 23, 2020 8:33 AM