The client ID and client secret are required to generate a valid access token.
Perform the following steps to generate the client ID and client secret:
-
Log in to the Microsoft Sharepoint Online account.
-
Enter the following site or subsite URL:Site: https://<sitename.com>/_layouts/15/appregnew.aspxSubsite: https://<sitename.com>/<subsitedomain>/_layouts/15/appregnew.aspxThe App Information page appears.
-
Click Generate next to the Client Id field.The value of the client ID is displayed in the Client Id field. The following image shows the App Information page where you can generate the values of the client ID and client secret:
-
Click Generate next to the Client Secret field.The value of the client secret is displayed in the Client Secret field.
- Enter an appropriate title for the App in the Title field.
-
Enter an app domain name in the App Domain field.For example, www.google.com
-
Enter a URL in the Redirect URL field. For example, https://localhost/. You must enter the same redirect URL in the connection property.
-
Click Create.
The page redirects to the Microsoft Sharepoint Online page and the following message appears:The app identifier has been successfully created.The values of the client Id, client secret, title, and redirect URL are displayed.
Important
Store the retrieved information (client id and client secret) since you'll need this in the next step!
follow this link for next step: Granting access using SharePoint App-Only | Microsoft Learn
If even with the correct ClientId and ClientSecret you have receiving the error:
The remote server returned an error: (401) Unauthorized.
the problem can be in Sharepoint settings, and can be fixed by the following PowerShell commands:
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Connect-SPOService -Credential $creds -Url https://abakionmdi-admin.sharepoint.com -ModernAuth
$true -AuthenticationUrl https://login.microsoftonline.com/organizations
#Get-SPOTenant
Set-SPOTenant -DisableCustomAppAuthentication $false
Comments
0 comments
Please sign in to leave a comment.