title: Using eBay OAuth
body: <p>I have my code as shown below. I am trying to authenticate users with eBay to be able to get access token. On redirecting users back to my redirection URL to exchange code with access token, I get the error: </p>
  
  <blockquote>
    <p>HTTP/1.1 100 Continue HTTP/1.1 400 Bad Request Content-Length: 109
    Cneonction: close Date: Thu, 02 Mar 2017 06:47:51 GMT RlogId:
    t6ldssk%28ciudbq%60anng%7Fu2h%3F%3Cwk%7Difvqn*2%3D%3F%3E505-15a8dc659e6-0xf3
    Set-Cookie: ebay=%5Esbf%3D%23%5E;Domain=.ebay.com;Path=/
    X-EBAY-C-REQUEST-ID: ri=v22kQg9yaBLq,rci=2FDiyansIYnkONQC
    X-EBAY-C-VERSION: 1.0.0 X-EBAY-REQUEST-ID:
    15a8dc658f8.a0968eb.5f6ef.fff87b7e![] Content-Type: application/json
    Connection: keep-alive
    {"error":"invalid_request","error_description":"'Authorization' is
    missing the the header:","error_uri":null}</p>
  </blockquote>
  
  <p>What is wrong with my POST request? </p>
  
  <pre><code>$auth_code = $_GET['code'];
  $client_id = "Client ID";
  $client_secret = "Client Secret";
  $redirect_uri = "RuName";
  $headers = array (
      'Content-Type'  =&gt; 'application/x-www-form-urlencoded',
      'Authorization' =&gt; sprintf('Basic %s',base64_encode(sprintf('%s:%s', $client_id, $client_secret)))
  );
  $apiURL = "https://api.sandbox.ebay.com/identity/v1/oauth2/token";
  $urlParams = array (
          "grant_type" =&gt; "authorization_code",
          "code" =&gt; urlencode($auth_code),
          "redirect_uri" =&gt; $redirect_uri
  );
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Should be removed on production
  curl_setopt ( $ch, CURLOPT_POST, 1 );
  curl_setopt ( $ch, CURLOPT_HEADER, true );
  
  curl_setopt($ch, CURLOPT_URL, $apiURL);
  curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers = array ('Authorization' =&gt; sprintf('Basic %s',base64_encode(sprintf('%s:%s', $client_id, $client_secret))),'Content-Type'  =&gt; 'application/x-www-form-urlencoded') );
  curl_setopt ( $ch, CURLOPT_POSTFIELDS, $urlParams );
  
  $resp = curl_exec ( $ch );
  curl_close ( $ch );
  
  print_r ( $resp );
  </code></pre>