Getting 401 Unauthorized error in sharepoint onpremise 2016

Purvesh Tejani 0 Reputation points
2023-02-16T05:08:18.39+00:00

We have SharePoint 2016 on-premise site
We successfully created one sp app using the SharePoint site
We are calling this request to get the code (so we can use the code for an access token)

https://sharepoint.tenant.com:/sites/live/_layouts/15/OAuthAuthorize.aspx?client_id=client-id&scope=Web.Manage&response_type=code&redirect_uri=https://sharepoint.tenant.com:**/sites/live**

we tried some solutions and finding more
If you have any idea about this error then us a solution.
If there is any other documentation for SharePoint on-premise 2016 then give us the link of that documentation.

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

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-02-16T06:58:53.61+00:00

    Hi @Purvesh Tejani,

    You can use following URL to get context token.

    • client_id: The client ID of your SharePoint Add-in.
    • redirect_uri: The URI to which you want the browser redirected after the new context token is obtained. SharePoint will POST the context token to this URI. Typically, this is the same page, controller method, or web service method that requested the new context token. The value must be URL-encoded.
    https://<SharePointDomain> /_layouts/15/appredirect.aspx?client_id=<app_client_GUID> &amp;redirect_uri=<URL-encoded_redirect_URI>
    
    

    Here is the document for details

    https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/handle-security-tokens-in-provider-hosted-low-trust-sharepoint-add-ins


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.