title: Obtain Azure Access Token
body: <p>i am getting this nasty error, i have no idea what i am doing wrong here. My code even looks quite similar to the one found on this blog, but in my case this is not working. </p>
  
  <p><a href="https://zimmergren.net/developing-with-azure-resource-manager-part-3-build-an-application-using-c-which-is-using-the-azure-resource-manager-apis/" rel="nofollow noreferrer">GetAzureAccessToken</a></p>
  
  <p>Error message </p>
  
  <blockquote>
    <p>"'authority' Uri should have at least one segment in the path (i.e. https:////...)\r\nParameter name: authority"</p>
  </blockquote>
  
  <pre><code>public static string GetAzureAccessToken(string clientId, string clientSecret)
      {
          string tenandId = "{tenandId}";
          string loginUri = $"https://login.windows.net/";
  
          var authCtx =
              new AuthenticationContext(String.Format(CultureInfo.InvariantCulture, loginUri, tenandId));
          var credential = new ClientCredential(clientId: clientId, clientSecret: clientSecret);
  
          var result = authCtx.AcquireToken(resource: "https://management.core.windows.net/",
              clientCredential: credential);
  
          if(result == null)
              throw new InvalidOperationException("Failed to aquire token");
  
          return result.AccessToken;
      }
  </code></pre>