We have built a desktop app that import/exports SharePoint lists into/from Office 365 sites. The app works perfectly, and we were able to do the import/export of Office 365 site pages for many clients so far.
but on a particular site, when I try to import some pages, I get the following error:
System.Net.WebException: The remote server returned an error: (403) Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetCookie(Uri url, String endpoint, String ticket)
at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticationCookie(Uri url, String username, SecureString password)
at Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, Boolean refresh)
at Microsoft.SharePoint.Client.ClientRuntimeContext.SetupRequestCredential(ClientRuntimeContext context, HttpWebRequest request)
at Microsoft.SharePoint.Client.SPWebRequestExecutor.GetRequestStream()
at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
Note that the account used for the authentication, has a Full Control permission on the site ( I can create sub-sites, lists, ...etc if logged in through a web browser )
I have also checked this answer, and we're already using SharePointOnlineCredentials
for authentication ( you can see that from the stack trace above )
So what is preventing me from doing the import through our desktop App ?
Note: I did not paste any code since the app is already battle tested and worked so many times before, and I do believe that the case here is some kind of settings on the client's site.
UPDATE
After some investigation, and thanks to @Evariste,
It seems that authentication is failing this time because the site is not using the classic Office 365 authentication model, and instead they're using the MAPI protocol
.