Jul 05 2023 11:44 PM - edited Jul 05 2023 11:47 PM
We are making SharePoint API calls for our on-premises SharePoint website
We are following the rest API's to get access token
in the first step
Request
https://sharepoint.tenat.com:*****/sites/live/_layouts/15/OAuthAuthorize.aspx?client_id=************...
after recalling this request getting the trust it option
but after that instead of code, we are getting this unauthorized error
Error
error=server_error&error_description=The%20remote%20server%20returned%20an%20error%3A%20%28401%29%20Unauthorized%2E
We also tried from the owner account still getting this error
In a normal SharePoint website, the API is working fine getting errors in the on-premises website
We are using Sharepoint 2016 on-premise
Jul 06 2023 02:19 AM
Hi @Jerror,
If you are getting the "401 Unauthorized" error, you can try:
1. Check if the owner account has the necessary permissions:
- Make sure that the owner account used for authentication has the appropriate permissions to access the SharePoint resources and perform the desired API actions.
- Verify that the owner account has full control (or the required permissions)
2.Ensure the SharePoint on-premises environment is configured for OAuth:
- Verify that the SharePoint 2016 on-premises environment has been properly configured to support OAuth authentication.
3. Confirm the URL and parameters:
- Double-check the URL you are using to request the access token and ensure it is correctly formatted and matches the SharePoint on-premises environment.
- Verify that all required parameters, such as client_id, redirect_uri, and other necessary parameters, are included and correctly specified in the request URL.
Please click Mark as Best Response & Like 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.
Kindest regards
Leon Pavesic
Jul 06 2023 04:03 AM - edited Jul 06 2023 04:15 AM
Thank you @LeonPavesic for your response we will check and get back to you.
Jul 06 2023 09:12 PM - edited Jul 06 2023 09:12 PM
Hi @LeonPavesic
Still, we are getting the same error
We checked all things, we tried from the admin account
May 17 2024 10:21 PM - edited May 17 2024 10:40 PM
Did you find the solution? I have same issue for getting on-premise access token.
I can get share point online access token with share point online resource id, but can’t find any document about how to get on-premise resource id.
If you resolved the problem, could you share the solution? Thank you.
May 17 2024 10:49 PM
May 18 2024 01:24 AM
May 20 2024 10:18 AM