title: How to get access to SharePoint with verification code
body: <p>I'm trying to make a webrequest to Sharepoint. Using my log-in credentials it returns a 403 error. I can make the same webrequest into a webbrowser, with the same credentials succesfully.</p>
  <p>The problem is that the webrequest authentication also requires a code. When I make the webrequest in a webbrowser it asks for a code and it requires me to press a button to send the code to my E-mail(See image below). How do I programatically authenticate with that code. Is there a work around for this? I couldn't find any solution so far on Stackoverflow.</p>
  <p>When I make the webrequest with a webbrowser, this window is prompted (This is what is causing the 403 error):
  <a href="https://i.stack.imgur.com/gbbJu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gbbJu.png" alt="enter image description here" /></a></p>
  <p>Using the following code:</p>
  <pre><code>        static void Main(string[] args)
      {
          string url = &quot;https://name.sharepoint.com/personal/mapname/_api/files&quot;;
          string login = &quot;classified&quot;;
          string pass = &quot;classified&quot;;
  
          //Create webrequest
          var request = WebRequest.Create(&quot;https://name.sharepoint.com/personal/mapname/_api/files&quot;) as HttpWebRequest;
          request.Credentials = new NetworkCredential(login, pass);
          var response = request.GetResponse();
  
      }
  </code></pre>