title: Upload File to SharePoint Online Library via Web Application
body: <p>I am trying to create a web application (ASP.NET MVC with C#) that allows a user to upload files to a SharePoint Online site. </p>
  
  <p>This code works when in SharePoint online <strong>only if</strong> I use my actual email and password.</p>
  
  <pre><code>    using (ClientContext context = new ClientContext(url))
      {
  
          var password = new SecureString();
  
          foreach(var c in "password")
          {
              password.AppendChar(c);
          }
  
          context.Credentials = new SharePointOnlineCredentials(email, password);
  
          //code to upload file
      }
  </code></pre>
  
  <p>But I do not want to use my credential for all the users of this web application. So, I've been doing some research on this and found about the Claim-based authentication.
  <a href="https://code.msdn.microsoft.com/Remote-Authentication-in-b7b6f43c#content" rel="nofollow noreferrer">https://code.msdn.microsoft.com/Remote-Authentication-in-b7b6f43c#content</a></p>
  
  <p>I'll definitely try this, but I'm still wondering if this is the only way to achieve what I want to do. The web application authenticates users with windows authentication, and so does the sharepoint online site. Is it really true that there's no way for the sharepoint online site to get the credential from the web application?</p>