CSOM code needs to use modern authentication

%3CLINGO-SUB%20id%3D%22lingo-sub-2065023%22%20slang%3D%22en-US%22%3ECSOM%20code%20needs%20to%20use%20modern%20authentication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2065023%22%20slang%3D%22en-US%22%3E%3CP%3ETo%20whom%20may%20be%20willing%20to%20help%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20an%20O365%20Global%20administrator%20with%20very%20little%20knowledge%20about%20code.%26nbsp%3B%20We%20run%20into%20issues%20and%20need%20help.%26nbsp%3B%20With%20no%20coding%20background%20I%20am%20seeking%20help%20for%20some%20basic%20knowledge%20to%20educate%20myself%20first.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20migrated%20all%20SharePoint%20sites%20to%20O365%20but%20site%20provisioning%20and%20some%20custom%20processes%20are%20still%20using%20old%20CSOM%20code%20developed%20while%20we%20were%20on-prem.%26nbsp%3B%20We%20use%20those%20for%20couple%20tasks%3A%3C%2FP%3E%3CP%3E1.%20site%20provisioning%3C%2FP%3E%3CP%3E2.%20Read%20list%20item%2C%20check%20date%20and%20send%20notification%20if%20items%20will%20expire%20soon%3C%2FP%3E%3CP%3E3.%20Search%20files%20and%20copy%20to%20other%20file%20share%20location%3C%2FP%3E%3CP%3E4.%20Rollup%20tasks%20to%20root%20site%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAll%20those%20customized%20code%20work%20fine%20until%20I%20configured%20SPO%20block%20access%20for%20%22Apps%20that%20don't%20use%20modern%20authentication%22%20--%20service%20account%20login%20failed.%26nbsp%3B%26nbsp%3BAfter%20troubleshooting%20and%20checking%20by%20other%20teammates%20I%20was%20told%20couple%20things%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E*%20SPO%20API%20works%20but%20not%20function%20properly%20with%20modern%20authentication%20method%3C%2FP%3E%3CP%3E*%20The%20PnP%20Core%20is%20in%20Beta%20which%20tends%20to%20have%20errors%20so%20isn't%20useful%20for%20production%20code%3C%2FP%3E%3CP%3E*%20The%20Graph%20API%20lacks%20some%20critical%20functionality%20so%20not%20useful%20neither.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20understand%20the%20statement%20and%20do%20some%20research%20to%20educate%20myself.%26nbsp%3B%26nbsp%3BI%20just%20read%20MS%20article%20%22Provisioning%20%22modern%22%20team%20sites%20programmatically%22%20where%20it%20talks%20about%20using%20PnP%20CSOM%20core%20component%20to%20provision%20sites.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20reading%20the%20article%20I%20have%20couple%20questions%20and%20wondering%20if%20someone%20is%20willing%20to%20help%20me%20understand%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%26nbsp%3BIt%20looks%20like%20the%20PnP%20Core%20component%20released%20on%2010%2F2017.%26nbsp%3B%20is%20it%20still%20in%20Beta%20and%20not%20use%20modern%20authentication%3F%20Or%20are%20they%20different%20components%3F%26nbsp%3B%20If%20it's%20latter%2C%20which%20one%20should%20be%20used%20for%20site%20provisioning%20and%20can%20do%20the%20modern%20authentication%3F%26nbsp%3B%20Is%20there%20any%20github%20example%20for%20such%20case%3F%26nbsp%3B%20I%20did%20google%20search%20which%20shows%20couple%20results.%26nbsp%3B%20But%20I%20don't%20know%20which%20one%20uses%20modern%20authentication.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2.%26nbsp%3B%20Just%20like%20SharePoint%20itself%20there%20are%20always%20several%20ways%20of%20doing%20the%20same%20tasks.%26nbsp%3B%20I%20heard%20about%20SharePoint%20framework%20and%20all%20those%20APIs%2C%20.NET%20core%2C%20etc.%26nbsp%3B%26nbsp%3BIn%20terms%20of%20tasks%20like%20what%20we%20are%20doing%20(site%20provisioning%2C%20read%2Fcopy%20files%2C%20etc)%2C%20which%20is(are)%20recommended%20method(s)%20for%20us%3F%26nbsp%3B%20I%20know%20it's%20a%20broad%20question%20and%20depends%20on%20the%20solutions%2Fscenarios.%26nbsp%3B%20I%20just%20want%20to%20know%20in%20general%20at%20high%20level%20when%20to%20use%20what%20so%20I%20can%20do%20more%20digging%20to%20learn%20more.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20information%20you%20can%20provide%20is%20greatly%20appreciated!%26nbsp%3B%20Thanks%20in%20advance!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESally%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2066763%22%20slang%3D%22en-US%22%3ERe%3A%20CSOM%20code%20needs%20to%20use%20modern%20authentication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2066763%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F37416%22%20target%3D%22_blank%22%3E%40C%20Lee%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20your%20requirements%2C%20I%20will%20recommend%20you%20to%20use%20Office%20Dev%20PnP%20Core%20library.%20This%20supports%20modern%20authentication%20as%20well%20using%26nbsp%3B%3CSTRONG%3EAuthenticationManager%3C%2FSTRONG%3E%20class%20which%20has%20various%20methods%20for%20authentication.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheck%20below%20links%20for%20more%20information%20on%20this%3A%3C%2FP%3E%3COL%3E%3CLI%3E%3CA%20title%3D%22PnP%20Core%20library%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fsolution-guidance%2Fpnp-provisioning-engine-and-the-core-library%23pnp-core-library%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPnP%20Core%20library%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3CLI%3E%3CA%20title%3D%22Provisioning%20console%20application%20sample%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fsolution-guidance%2Fprovisioning-console-application-sample%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EProvisioning%20console%20application%20sample%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3CLI%3E%3CA%20title%3D%22Authentication%20to%20SharePoint%20Online%20with%20CSOM%22%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F52707476%2Fauthentication-to-sharepoint-online-with-csom%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EAuthentication%20to%20SharePoint%20Online%20with%20CSOM%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3C%2FOL%3E%3CHR%20%2F%3E%3CP%3EPlease%20click%20%3CSTRONG%3EMark%20as%20Best%20Response%3C%2FSTRONG%3E%20if%20my%20post%20helped%20you%20to%20solve%20your%20issue.%20This%20will%20help%20others%20to%20find%20the%20correct%20solution%20easily.%20It%20also%20closes%20the%20item.%20If%20the%20post%20was%20useful%20in%20other%20ways%2C%20please%20consider%20giving%20it%20%3CSTRONG%3ELike%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2071231%22%20slang%3D%22en-US%22%3ERe%3A%20CSOM%20code%20needs%20to%20use%20modern%20authentication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2071231%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F373269%22%20target%3D%22_blank%22%3E%40ganeshsanap%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20kindly%20sharing%20your%20experiences%20and%20the%20links.%26nbsp%3B%20Really%20appreciate%20your%20help!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESally%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

To whom may be willing to help,

 

I am an O365 Global administrator with very little knowledge about code.  We run into issues and need help.  With no coding background I am seeking help for some basic knowledge to educate myself first.  

 

We have migrated all SharePoint sites to O365 but site provisioning and some custom processes are still using old CSOM code developed while we were on-prem.  We use those for couple tasks:

1. site provisioning

2. Read list item, check date and send notification if items will expire soon

3. Search files and copy to other file share location

4. Rollup tasks to root site

 

All those customized code work fine until I configured SPO block access for "Apps that don't use modern authentication" -- service account login failed.  After troubleshooting and checking by other teammates I was told couple things:

 

* SPO API works but not function properly with modern authentication method

* The PnP Core is in Beta which tends to have errors so isn't useful for production code

* The Graph API lacks some critical functionality so not useful neither.  

 

I am trying to understand the statement and do some research to educate myself.  I just read MS article "Provisioning "modern" team sites programmatically" where it talks about using PnP CSOM core component to provision sites. 

 

After reading the article I have couple questions and wondering if someone is willing to help me understand:

 

1. It looks like the PnP Core component released on 10/2017.  is it still in Beta and not use modern authentication? Or are they different components?  If it's latter, which one should be used for site provisioning and can do the modern authentication?  Is there any github example for such case?  I did google search which shows couple results.  But I don't know which one uses modern authentication.

 

2.  Just like SharePoint itself there are always several ways of doing the same tasks.  I heard about SharePoint framework and all those APIs, .NET core, etc.  In terms of tasks like what we are doing (site provisioning, read/copy files, etc), which is(are) recommended method(s) for us?  I know it's a broad question and depends on the solutions/scenarios.  I just want to know in general at high level when to use what so I can do more digging to learn more.  

 

Any information you can provide is greatly appreciated!  Thanks in advance!!!

 

Sally

2 Replies

@C Lee 

 

For your requirements, I will recommend you to use Office Dev PnP Core library. This supports modern authentication as well using AuthenticationManager class which has various methods for authentication.

 

Check below links for more information on this:

  1. PnP Core library 
  2. Provisioning console application sample 
  3. Authentication to SharePoint Online with CSOM 

Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

 

@ganeshsanap 

 

Thanks for kindly sharing your experiences and the links.  Really appreciate your help!

 

Sally