3

I want to authenticate against sharepoint online site using SharepointOnlineCredentials class. Below code works fine in a console application. But the same code is generating error when written in wcf data service and consumed in a provider hosted app.

  ClientContext clientContext = new ClientContext("<Sharepoint online site url>");
  SecureString securePassword = new SecureString();
  foreach (char c in _password)
  {
      securePassword.AppendChar(c);
  }
  //Generates exception on this step. Exception details provided below
  SharePointOnlineCredentials creds = new SharePointOnlineCredentials(_username, securePassword);
  clientContext.Credentials = creds;

Exception Details:

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.CheckHResult(Int32 hr) at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.EnsureInited() at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.LogonIdentity(String username, SecureString password) at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.Logon(String username, SecureString password) at Microsoft.SharePoint.Client.SharePointOnlineCredentials..ctor(String username, SecureString password)

1 Answer 1

1

The way the SharePointOnlineCredentials must be used differ from a client app versus web service - i believe this example explains it http://tomaszrabinski.pl/wordpress/2013/03/18/connecting-to-office-365-using-client-side-object-model-and-web-services/

1
  • 1
    I visited the link and tried what he has suggested.. but it does not solve my problem. Commented Jan 2, 2014 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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