title: curl terminal - POST request with Basic Authorization and body containing authorization code
body: <p>i have following params:</p>
  
  <pre><code>$url = "https://example.com/auth_token.json"
  $clientId = "...", $secretId = "..."
  $callback = "http://example"
  $code = "1234" - # i've received if earlier, 
  
  $body = "grant_type=authorization_code&amp;code=$code&amp;redirect_uri=$callback"
  </code></pre>
  
  <p>My goal is to get token with code, service says :</p>
  
  <p>"Send a POST request to $url, providing the Client ID and Secret Key as HTTP Basic Authorization credentials, and a post body containing grant_type=authorization_code
  and get in response json with token."</p>
  
  <p>I tried something like this</p>
  
  <pre><code>curl $url --verbose -d $body -X -POST
  </code></pre>
  
  <p>but answer is - Status :401, nonauthorized and json "Unauthorized client or authentication failed, check your credentials."</p>
  
  <p>then i tried to add </p>
  
  <pre><code>-H "Authorization : Basic ...encoded value..."
  </code></pre>
  
  <p>and get "Bad request"</p>
  
  <p>Help me please, i missed something, 
  thx</p>