title: Microsoft Azure get access token API not working with cURL/Ruby but works with powershell
body: <p>I am simply trying to get an access token from client id, client secret and tenant ID. Following powershell command works successfully </p>
  
  <pre><code>Invoke-RestMethod -Uri https://login.microsoftonline.com/TENANT/oauth2/token?api-version=1.0 -Method Post -Body @{"grant_type" = "client_credentials"; "resource" = "https://management.core.windows.net/"; "client_id" = "CLIENTID"; "client_secret" = "SECRET" }
  </code></pre>
  
  <p>But this curl doesn't work</p>
  
  <pre><code>curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=client_credentials&amp;resource=https://management.core.windows.net/&amp;client_id=CLIENTID&amp;client_secret=SECRET" "https://login.microsoftonline.com/TENANT/oauth2/token?api-version=1.0"
  </code></pre>
  
  <p>Neither this ruby script</p>
  
  <pre><code>require 'json'
  require 'typhoeus'
  
  url = 'https://login.microsoftonline.com/TENANT/oauth2/token?api-version=1.0'
  params = "grant_type=client_credentials&amp;resource=https://management.core.windows.net/&amp;client_id=CLIENTID&amp;client_secret=SECRET"
  HEADERS = {
  "Content-Type" =&gt; "application/x-www-form-urlencoded"
  }
  resp = Typhoeus::Request.post(url, body: params, headers: HEADERS)
  </code></pre>
  
  <p>I am following <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-rest-api#calling-resource-manager-rest-apis" rel="nofollow noreferrer">this</a> link. Any clues why neither of curl / ruby works ?
  Thanks in advance</p>