简体   繁体   中英

How to logout from Sharepoint with CSOM

I am using CSOM library with C# to upload some files to SharePoint. One requirement is to use 2FA. Basically, I am following this post: https://knowledge-junction.com/2017/12/24/office-365-connecting-to-sharepoint-online-site-using-csom-when-multi-factor-authentication-mfa-is-enabled-for-the-user/

The login is done with the help of SharePointPnPCoreOnline library. This is working perfectly.

When the user selects "remember me" during the login procedure, the user stays logged in even when the app is restarted. Now, I am wondering how can I manually log out? I do not see any method or hint how to do that.

You can take a look at the code which is used to sign-in https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/AuthenticationManager.cs

and per analogiam do the sign-out with the URL " https://login.microsoftonline.com/common/oauth2/logout ".

AuthenticationManager uses IE browser to perform web login and saves auth cookies in CookieContainer. So you need to delete them. Open IE->Settings->InternetOptions->Browsing history->Delete Select Cookies and website data checkbox-> Delete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM