'AuthenticationManager' does not contain a constructor that takes 0 arguments

Valued Contributor

I have the following code to connect to SharePoint using clientID and ClientSecret:-


    string siteUrl = "https://****l.sharepoint.com/sites/DocumentApprovalProcess/";
    string clientId = "***";
    string clientSecret = "**";
    using (var context = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, clientId, clientSecret))



but i am getting this error:-

'AuthenticationManager' does not contain a constructor that takes 0 arguments

2 Replies

@john john 


The method you are trying to use is available in OfficeDevPnP.Core. You can install it from here.


Microsoft documentationAuthenticationManager.GetAppOnlyAuthenticatedContext Method 


You can check below reference to check how you can use this method:

Connect To SharePoint Online Site With App Only Authentication 

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.


When you provided a constructor for your class that takes arguments, the compiler no longer creates an empty constructor. Therefore, you cannot call an empty constructor because it does not exist. You would need to explicitly write the constructor that takes 0 arguments in your class's code. The constructor of the inheritance class needs to construct the base class first. since the base class does not have a default constructor (taking 0 arguments) and you are not using the non-default constructor you have now, this won't work. so either:


  • Add a default constructor to your base class, in which case the code of the descending class needs no change;


  • Call the non-default constructor of the base class from the constructor of the descending class, in which case the base class needs no change.