Prompt O365 Authentication for Acess to SharePoint Lists through App

Christian Puhr 1 Reputation point
2021-03-22T12:01:50.827+00:00

Hello all!

I have developed a VB.NET app which reads/writes data from/to SharePoint Online lists. My organization uses the Office 365 two-factor authentication with Autheticator app. Now, it is possible to add my login credentials to the code allowing me to access the lists. However, this is not a good solution as other users of my app always use my login data.

Is there a way to trigger the normal O365 authentication (e.g. through opening a web browser window)? Like Teams, Skype or Outlook do? That way the access could work on a per-user basis.

Thank you for your response!

Best regards,

Christian

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
6,081 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Amos Wu-MSFT 4,021 Reputation points
    2021-03-23T02:25:30.317+00:00

    Try to use the GetWebLoginClientContext method in OfficeDevPnP.Core.AuthenticationManager. When we use this method, it opens a pop-up with the standard tenant login page, and users will be prompted for the credentials and challenges for the second-factor authentication.
    Refer to this blog for details:Sharepoint: Connect to site with MFA enabled using CSOM and PnP PowerShell


    If the response is helpful, please click "Accept Answer" and upvote it.
    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.

    No comments

  2. Christian Puhr 1 Reputation point
    2021-03-23T08:38:19.117+00:00

    Hello!

    Thank you! I do not seem to have that installed and might not be able to get it in my corporate environment.

    Maybe there is another way.

    Best regards,

    Christian