title: eBay API always returning invalid_client on production but sandbox works fine
body: <p>I've been at this for several days now, and I can't seem to find the solution.</p>
  
  <p>I'm trying to authorize via ebay API to get a user token for further actions. </p>
  
  <p>When I use sandbox environment, it all works great, however as soon as I use production, I get the following error:</p>
  
  <pre><code>{"error":"invalid_client","error_description":"client authentication failed"}
  </code></pre>
  
  <p>My file structure is as follows:</p>
  
  <p>config.php:</p>
  
  <pre><code>&lt;?php
      /* SAndbox 
  $config = [
      'client_id' =&gt; 'xxxxx-xxxxxx-SBX-e55b66fda-63c7e331',
      'client_secret' =&gt; 'SBX-xxxxxx-dxxxxxb-47cb-9bee-f33b',
      'ru_name' =&gt; 'xxxxxxxxx-oxxxxas-xxxxxxx-tsuggc',
      'login_url' =&gt; 'https://auth.sandbox.ebay.com/oauth2/authorize',
      'oauth_url' =&gt; 'https://api.sandbox.ebay.com/identity/v1/oauth2/token',
      'api_scopes' =&gt; ['https://api.ebay.com/oauth/api_scope/sell.inventory'],
  ];
  */
  
  $config = [
      'client_id' =&gt; 'xxxxxx-CxxxxxxT-PRD-455bfe8ea-7e445131',
      'client_secret' =&gt; 'PRD-797xxxx7bf-d5xxxc-4a19-axxade-ab8xx6',
      'ru_name' =&gt; 'xxxxxxx-osxxxxxxas-CxxxxS-hjlalp',
      'login_url' =&gt; 'https://auth.ebay.com/oauth2/authorize',
      'oauth_url' =&gt; 'https://api.ebay.com/identity/v1/oauth2/token',
      'api_scopes' =&gt; ['https://api.ebay.com/oauth/api_scope/sell.inventory'],
  ];
  </code></pre>
  
  <p>getLogin.php:</p>
  
  <pre><code>&lt;?php
  include_once 'config.php';
  
  $url = $config['login_url'];
  $url .= '?client_id='.$config['client_id'];
  $url .= '&amp;response_type=code';
  $url .= '&amp;redirect_uri='.urlencode($config['ru_name']);
  $url .= '&amp;scope='.implode(' ', $config['api_scopes']);
  echo "&lt;a href='{$url}'&gt;login&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;";
  
  
  die();
  </code></pre>
  
  <p>login.php(where I get redirected after authorization):</p>
  
  <pre><code>&lt;?php
  include_once 'config.php';
  echo "&lt;pre&gt;";
  $code = $_GET['code'];
  $authorization = 'Basic '.base64_encode($config['client_id'].':'.$config['client_secret']);
  print_r($config);
  $curl = curl_init();
  
  curl_setopt_array($curl, [
      CURLOPT_URL =&gt; $config['oauth_url'],
      CURLOPT_RETURNTRANSFER =&gt; true,
      CURLOPT_ENCODING =&gt; "",
      CURLOPT_MAXREDIRS =&gt; 10,
      CURLOPT_TIMEOUT =&gt; 30,
      CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST =&gt; "POST",
      CURLOPT_POSTFIELDS =&gt; "grant_type=client_credentials&amp;code=".$code."&amp;redirect_uri=".$config['ru_name'],
      CURLOPT_HTTPHEADER =&gt; [
          "Authorization: ".$authorization,
          "Content-Type: application/x-www-form-urlencoded",
          "cache-control: no-cache",
      ],
  ]);
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  $info = curl_getinfo($curl);
  curl_close($curl);
  
  
  
  
  print_r($info);
  if ($err) {
      echo "cURL Error #:".$err;
  } else {
      echo 'resp: '.$response;
  }
  </code></pre>
  
  <p>Any and all help would be appreciated, as i'm about to pull my hair out over this!</p>