Ever need to access a SharePoint online site from a Visual Studio Console application? In this article, we will show you how. This is the best way to access your Sharepoint artifacts without a service account or user-id/password combination. Instead, register an App then generate a secret key. You can then use the secret key to access your SharePoint environment via an application
Step 1: How to Register a new app
Go to -> https://site/_layouts/15/AppRegNew.aspx
Click Generate to create App Id and App Secret then save the values for use in later steps. You can give descriptive language as Title and App Domain, then enter a Redirect URI.
Step 2: How to give permission to the App ID created in Step 1
Go to -> https://site/_layouts/15/appinv.aspx
Enter the App ID you created in Step 1 then click on the Lookup button. SharePoint will find the account and fills the rest of the values, In Permission Request XML, paste the below XML
Step 3: Check whether your app is available in the Site App Permission list
Go to Site Settings -> Site app permission or (https://site/_layouts/15/appprincipals.aspx )
Now we have an app which can access SharePoint with Full Control