trying to get access token using sharepoint onpremise api but getting error in first step

Copper Contributor

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

7 Replies

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

Thank you @LeonPavesic  for your response we will check and get back to you.

Hi @LeonPavesic 
Still, we are getting the same error
We checked all things, we tried from the admin account

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.

Hi,
We did not get any solution for this till now.
Thank you for quick reply, I will continue the research.
I found a way to get resource id, but have to confirm if it works by Postman when my test env set up. But you can take a try and let me know if works for you. Follow this link: https://youtu.be/iJDbg8dDRhE?si=xIq6uFEFaWiD85Jh