title: Connecting to SharePoint online using CSOM in a Windows Store App
body: <p>I want toe make my windows 8.1 store app, which communicates with SharePoint 2013, compatible with SharePoint online. This is my code so far:</p>
  
  <pre><code>var context = new ClientContext(siteUrl);
  
  try
  {
      Regex rgx = new Regex(@"@");
      if (rgx.IsMatch(CredentialHelper.GetSharePointCredentialsFromVault().UserName))
      {
          context.Credentials =
                  new SharePointOnlineCredentials(
                  CredentialHelper.GetSharePointCredentialsFromVault().UserName,
                  CredentialHelper.GetSharePointCredentialsFromVault().Password);
      }
      else
      {
          context.Credentials = CredentialHelper.GetSharePointCredentialsFromVault();
      }
  
      var site = context.Web;
  
      context.Load(site);
      await context.ExecuteQueryAsync();
      isLoggedIn = true;
      }
  </code></pre>
  
  <p>So, when there is an '@' character in the username I asume for now it's targeting a SharePoint online environment and uses SharePointOnlineCredentials. otherwise it uses SharePoint on premise credentials.</p>
  
  <p>If I type in my SharePoint online creds, it keeps showing an exception which says "The sign-in name or password does not match one in the Microsoft account system.". I'm sure I did type in the right creds...</p>
  
  <p>Can any one help me with this?</p>
  
  <p>Thanks in advance.</p>