title: Get oauth token for Azure Key Vault
body: <p>Trying to get an oauth2 token for Azure Key Vault, following the tutorial below. </p>
  
  <p><a href="https://docs.microsoft.com/en-us/azure/key-vault/general/tutorial-net-windows-virtual-machine" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/key-vault/general/tutorial-net-windows-virtual-machine</a></p>
  
  <p>Within Azure I am getting the oauth2 token endpoint and making the call to get the token, but getting a response "You must sign into your account". Is the token endpoint supposed to be different? if so where is that found? If I am using the correct endpoint, then how to solve this because the whole purpose of using Key Vault is so that you don't have to store your credentials locally</p>
  
  <pre><code>    static string GetToken()
      {
          WebRequest request = WebRequest.Create("https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token");
          request.Headers.Add("Metadata", "true");
          WebResponse response = request.GetResponse();
          return ParseWebResponse(response, "access_token");
      }
  </code></pre>