sharepoint online – SPO security trimmed search results in a web application

Wondering if you can help, I have scoured the internet and can’t find anyone with the same issue.

Looking for a way for a user to login to the web application (completely internal) using their O365 credentials (interactively if no cookie) then make a call using CSOM to return search results, in the context of the user.

The problem I have is, I need to connect to SharePoint and can’t find to link the authorization to the creation of the ClientContext. The only way I can connect to SharePoint is by using an AppOnly approach, which results in the search results not being security trimmed.

I have had some success with the PnP GetWebLoginClientContext but this frequently pops up with a small white box everytime try to use it. Which offers a poor user experience.

Was hoping someone has experience of a more elegant way to connecting to SharePoint, it’s difficult to find anything out there.

Hoping someone has some ideas.

Thank you!