It's best to try Method#2 first as it contains fewer steps. See below:
Please follow the steps below in order to enable OAuth 2 on your Sharepoint environment and connect to the portal:
Method #1
Create an application under Azure AD
Navigate to: https://admin.microsoft.com
Login with your Sharepoint credentials
On the left pane, click Show All
Under Admin Centers, click “Azure Active Directory”
In Azure portal, click “Azure Active Directory” in the left pane
Under Manage, click App Registrations
Click New registration on the toolbar
Enter “Sharepoint OAuth 2” for the application name
Select the second option:
Accounts in any organizational directory (Any Azure AD directory - Multitenant)
Under Redirect URI, select “Web” and enter “http://localhost”
Click “Register”
Set API Permissions
Under Manage, click “API permissions”
Click, “Add a permission” on the toolbar
Select “Sharepoint” on the “Request API permissions” dialog
Select the “Delegated permissions” box, (It is highlighted in gray when selected).
Give required permissions (eg. AllSites.FullControl, MyFiles.Read, User.Read.All, etc.)
Click Add permissions
Grant Admin Consent
Click “Grant admin consent for <company name>” on the toolbar and click “Yes” on the confirmation dialog box.
Update the Manifest
Under Manage, click Manifest
Set the allowPublicClient to true
Set the oauth2AllowIdTokenImplicitFlow to true
Set the oauth2AllowImplicitFlow to true
Click Save
Create a secret key:
Under Manage, click Certificates & secrets
Click, New client secret on the toolbar
Enter Sharepoint Secret in the Description
From Expires dropdown, select 24 Months
Click Add
Your secret is added. Copy the code under the Value column and keep it in a safe place
Copy required information
In the menu, click Overview
Copy the Application (Client) ID by clicking the copy button
Copy the Directory (Tenant) ID by clicking the copy button
Give permission to create the application
Navigate to: https://<your_company>.sharepoint.com/_layouts/15/appinv.aspx where <your_company> is your domain name for the sharepoint.
Enter the Application (Client) ID that you copied before in the App ID field
Click Lookup
Enter your Magentrix domain name in the App Domain field
Copy and paste the following XML in the Permission Request XML field:
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope=" http://sharepoint/content/sitecollection" Right="FullControl"/>
</AppPermissionRequests>
Click Create
Click Trust It
Method #2
Register a Sharepoint application
Navigate to: https://<your_company>.sharepoint.com/_layouts/15/appregnew.aspx
Click the Generate button for Client Id
Click the Generate button for Client Secret
For Title, enter: Sharepoint oAuth App
For App Domain, you can enter your company domain
For Redirect Uri, enter: https://localhost
Click Create
Copy the Client ID and Client Secret
Give permission to the newly created Sharepoint application
Navigate to: https://<your_company>-admin.sharepoint.com/_layouts/15/appinv.aspx
Enter the Client ID in the App ID field and click the Lookup button
Copy and paste the following in the Permission Request XML field:
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
</AppPermissionRequests>
Click Create
Click Trust It
Setup Sharepoint credentials in Magentrix
Enter AppID and SecretValue in Magentrix
Login to your Magentrix portal with an Admin account
Go to: Setup > Extend > Connected Apps
Select Sharepoint from the list and click on Edit button
Enter the AppID (Client ID) in the Username field
Enter the Client Secret in the Password field
Enter the TenantID in the Security Token field
Click on Save button
Optional Steps: How to test in Postman
Get Authentication Token
Open a new tab and set the action as POST
Address: https://accounts.accesscontrol.windows.net/{TENANT_ID}/tokens/oAuth/2
Under Body select form-data and add the following:
grant_type client_credentials
client_id {CLIENT_ID}@{TENANT_ID}
client_secret {SECRET_VALUE}
resource: 00000003-0000-0ff1-ce00-000000000000/<YOUR_COMPANY_DOMAIN>.sharepoint.com@{TENANT_ID}
Click on Send button and you should get the auth token
Querying Data
Open a new tab and set the action as GET
Address: https://<your_company>.sharepoint.com/_api/Web/Lists/{Entity}/Items
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
Authorization: Bearer {TOKEN_FROM_ABOVE}
Click on Send button and you should get the result with HTTP status code 200
If the result is an empty array
Launch Powershell in Admin mode
Enter: Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Enter: Connect-SPOService -Url https://<your_company>-admin.sharepoint.com -Credential user@magentrixsbx.onmicrosoft.com
Enter your password
Enter: set-spotenant -DisableCustomAppAuthentication $false
Note: To access the Sharepoint applications settings page, go to the following URL:
https://<your_company>.sharepoint.com/_layouts/15/settings.aspx