-
-
Save vman/37bab1e1d700be238011f1de23a3e275 to your computer and use it in GitHub Desktop.
using Microsoft.SharePoint.Client; | |
using OfficeDevPnP.Core; | |
using System; | |
namespace CSOMDemo | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var authManager = new AuthenticationManager(); | |
var ctx = authManager.GetWebLoginClientContext("https://contoso.sharepoint.com/"); | |
Web web = ctx.Web; | |
User user = web.CurrentUser; | |
ctx.Load(web); | |
ctx.Load(user); | |
ctx.ExecuteQuery(); | |
Console.WriteLine(web.Title); | |
Console.WriteLine(user.LoginName); | |
Console.ReadLine(); | |
} | |
} | |
} |
This API is no longer in the SharePointPnPCoreOnline Nuget package.
Any ideas where this API can be found now?
try to install an older version that is 3.12.1908 then you can able to use "using OfficeDevPnP.Core;"
Hello, I am getting following error at? authManager.GetWebLoginClientContext(siteUrl);
Error CS0012 The type 'Icon' is defined in an assembly that is not referenced.You must add a reference to assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
and If install System.Drawing.Common package, Getting
"Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral" this error.
Any Idea how to solve this? I am using console app project with VS 2019 Thanks.
**UPDATE
I was using .net Core which is not supported changed to .net 4.7.4
I am working on provider hosted app with MFA enabled for SharePoint online. Can you please suggest what are the options for user authentication.
Hello, I am getting following error at? authManager.GetWebLoginClientContext(siteUrl);
Error CS0012 The type 'Icon' is defined in an assembly that is not referenced.You must add a reference to assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
and If install System.Drawing.Common package, Getting
"Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral" this error.
Any Idea how to solve this? I am using console app project with VS 2019 Thanks.
**UPDATE
I was using .net Core which is not supported changed to .net 4.7.4
Did this solve after changing the .net framework from .net core? Have you developed this in Web or Windows App?
Yes, you must definitely use a Windows Forms project in .NET Framework 4.x
OfficeDevPnP.Core.AuthenticationManager is part of the PnP Core Library available here: https://www.nuget.org/packages/SharePointPnPCoreOnline