Creating credentials using SharePoint App

You can use a SharePoint App-Only to connect to the Microsoft SharePoint Online server from a SharePoint REST Connection shared resource with OAuth. Perform the following steps:

  • Register an app in SharePoint Online and generate the Client ID and Client SecretKey
  • Grant tenant full control permissions to the app

To obtain the OAuth values for your app, perform the following procedure.

Register Add-In
  1. Go to https://{tenant}.sharepoint.com/_layouts/15/appregnew.aspx. this will redirect to the Register Add-In page.
  2. In the App Information section, click the Generate button next to the Client ID and Client SecretKey textboxes to generate the respective values.
  3. Set Title, App Domain, and Redirect URI by filling respective fields.
  4. Click Create button, which registers the add-in and returns the success message with created information.
Note: Note down the Client ID and Client SecretKey for the next steps.
Grant Permissions to Add-In
  1. To grant tenant scoped permissions to the app, visit https://{tenant}-admin.sharepoint.com/_layouts/15/appinv.aspx on the tenant administration site this will redirect to the grant permission page.
  2. Enter the Client ID (which we have generated earlier) in the App Id textbox and click the Lookup button that will populate the value to other textboxes in Title, App Domain, and Redirect URI.
  3. Now enter the below permission request in XML format.
    AppPermissionRequests AllowAppOnlyPolicy="true"
    AppPermissionRequest Scope="http://sharepoint/content/tenant"
    Right="FullControl"
    AppPermissionRequests
    Note: In the above XML, scope attribute value can be either tenant or sitecollection. For more information about add-in permissions in SharePoint, see https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-in-permissions-in-sharepoint?source=recommendations.
  4. Click Create, a permission consent dialog box is displayed.
  5. Click Trust It to grant the permissions.
Note: The {tenant} is the initial domain name of Azure AD organization.