Search code examples
c#.net-coresharepoint-apisharepoint-2016

Authenticate user & call REST API sharepoint on-premise using token


I'm working on a .net core web application. I need to call REST apis of a sharepoint on-premise site.

I can do it using some methods, but they all require to hardcode username and password.

I did it with a sharepoint online site & Azure AD. But i don't find a solution for on-premise..

Is there a way to authenticate user and get an access token to call REST apis ?

Edited for information :

As i need to get information on behalf on the current user. i Did not found a solution yet, for a .net core web app.

But i can do that by using CSOM in a .net standard web app.

Thanks for helps. Tristan Sébillet


Solution

  • You should be able to do this with a appsettings.json file. Inside you will need something like:

    "AuthClientId": (ID HERE)
    "AuthClientSecret":(PIN / CODE HERE)
    "AuthSubscriptionKey":(SUBSCRIPTION HERE)
    "AuthRedirectUri": (REDIRECT HERE)