getting error in access token process in sharepoint onpremise 2016 api

256 Views Asked by At

We are trying to get an access token in SharePoint on-premises 2016 server version.

Creating an app successfully using these steps in our SharePoint on-premise 2016: https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs

Following these steps for an access token:

Get code request:

https://sharepoint.tenant.com:0000/sites/live/_layouts/15/OAuthAuthorize.aspx?client_id=0000000-0000-0000-0000-00000000&response_type=code&redirect_uri=https://sharepoint.tenant.com:0000/sites/live/default.aspx&scope=Web.Manage Not getting code.

But getting 401 unauthorized error in the access token process

error=server_error&error_description=The%20remote%20server%20returned%20an%20error%3A%20%28401%29%20Unauthorized%2E

Note: I am using admin account.

We trying to upload file in sharepoint onpremise 2016 server using api. App creation using in website done properly we are getting client id and client secret but after that when we trying to get access token in tokens first request where we get code using in url we are getting error 401 unauthorized.

1

There are 1 best solutions below

2
Gaurav T On

Since you get a 401 error it is related to app permissions. Did you grant this app permissions using the "/_layouts/15/appinv.aspx" page and XML below as stated in the MS document?

<AppPermissionRequests AllowAppOnlyPolicy="true">
  <AppPermissionRequest Scope="http://sharepoint/content/SiteCollection" Right="FullControl" />
</AppPermissionRequests>