Connect to SharePoint Online from ADAL protected MVC web app with logged in user's identity

Copper Contributor



We are trying to surface the results of our SharePoint Online search in an ADAL protected MVC web app.


Looking at the SharePoint Online PnP Core CSOM extensions (OfficeDevPnP.Core namespace), it looks like the method AuthenticationManager.GetAzureADWebApplicationAuthenticatedContext(String, Func) would be the way to go. However, We've been unable to find any useful documentation on this method (or the SharePoint Online PnP package as a whole), in particular on how to obtain access tokens, or any working examples that do not include hard coding usernames and passwords. All the resources we've been able to find on the subject are either incomplete or out of date.


Does detailed documentation exist for this package? Or any working examples?




Failing that, is there a way to achieve this by some other means?

2 Replies
best response confirmed by Heisenberg (Copper Contributor)

Does this sample code still work?

Using Client ID and Client Secret of the application to get the context?

@Beau Cameron Yep, that did it! Thanks for your reply.

Actually it was the MicrosoftGraphHelper.GetAccessTokenForCurrentUser method where the magic was - we just weren't getting the right access tokens. 



1 best response

Accepted Solutions
best response confirmed by Heisenberg (Copper Contributor)