10

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.

  • 2
    Do they use the same authentification mechasnim? Maybe they're going with ADFS identities... – Evariste Dec 22 '15 at 13:58
  • @Evariste yes same authentication, what do you mean by "they're going with ADFS identities", can you explain more ? what are they doing exactly, and how using ADFS will block external API calls access ? – Anas Nakawa Dec 22 '15 at 14:27
  • 2
    I see your error raises while trying to authenticate your API calls. In Office 365, you may have 2 different authentication modes: the "classic" one with an Office 365 user address/password, and the federated. mixed mode one when Customer sync AD accounts with the accounts stored in Office 365. He uses ADFS for this. Authentication mechanism is then a little bit different I think. – Evariste Dec 22 '15 at 14:31
  • @Evariste you're right, they're not using the classic authentication model, they are using MAPI protocol, how that would affect our situation here, thanks ? – Anas Nakawa Dec 23 '15 at 8:35
  • 2
    Never heard about a "MAPI protocol" to authenticate against SP. :( MAPI is a messaging protocol used by Outlook and Exchange to access email stores and communicate. – Evariste Dec 23 '15 at 9:01
0

This happened to me one fine day where a program that used to collect metrics from SP Online site suddenly stopped working (it has worked for 1 month till them). No passwords were changed and the user was still active.

Finally found the issue. Classic MS System Restart fixed everything.

In my system I access a lot of tenants and MS websites which at some point messed up my cookies and cache I believe.

After restart, the program started working fine without any changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.