I have a requirement like creating .net core console application to communicate with SharePoint Online Resources using Graph API. while surfing i found only Access token is using to communicate with SharePoint. Is there any way to use SharePoint Online credentials with Graph API to communicate with SharePoint online?


You can do this using the SharePoint Online Client Object Model as long as your are willing to use the full .NET Framework. At this point in time the library does not support .NET Core.

Here's some sample code you can use to get started:

var siteUrl = "https://contoso.sharepoint.com";
var loginName = "george@contoso.onmicrosoft.com";
var password = "bosco";

var securePassword = new SecureString();
password.ToCharArray().ToList().ForEach(c => securePassword.AppendChar(c)); 

using (var context = new ClientContext(siteUrl))
    context.Credentials = new SharePointOnlineCredentials(
        loginName, securePassword);

    var web = context.Web;
    var list = web.Lists.GetByTitle("Site Pages");

    var query = new CamlQuery();
    query.ViewXml = "<View />";
    var items = list.GetItems(query);
    context.Load(items, c => c.Include(li => li.File.Name));

    foreach (var item in items)
  • Hi Rob,Thanks for the reply, Client don't want to do it in CSOM, they want to do it in Graph API.. – Parthasarathy Sep 11 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.