title: Api key authentication for coinbase
body: <p>I'm trying to write a request for API coinbase.com, but I can not correctly generate a signature. I've been trying to find my mistake for 2 days, but I can not. I analyzed the code for other languages on the page: <a href="https://developers.coinbase.com/docs/wallet/api-key-autumnicathion" rel="nofollow noreferrer">https://developers.coinbase.com/docs/wallet/api-key-autumnicathion</a> but I do not see any differences in implementation.</p>
  
  <p>Help me please.</p>
  
  <pre><code>&lt;?php
  $g_coinbase_key = 'KcxisxqmWRVgtwsj';
  $g_coinbase_secret = 'isOLGBLaEkCy3ROQMvmjonGmXK0KRmUS';
  
  $time = time();
  $method = "GET";
  $path = '/v2/accounts/';
  $sign = base64_encode(hash_hmac("sha256", $time.$method.$path, $g_coinbase_secret));
  $ch = curl_init('https://api.coinbase.com'.$path);
  $headers = array(
      "CB-VERSION: 2017-10-26",
      "CB-ACCESS-SIGN: ".$sign,
      "CB-ACCESS-TIMESTAMP: ".$time,
      "CB-ACCESS-KEY: ".$g_coinbase_key,
      "Content-Type: application/json"
  );
  curl_setopt($ch, CURLOPT_HTTPGET, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($ch);
  var_dump($result);
  ?&gt;
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>{"errors":[{"id":"authentication_error","message":"invalid signature"}]}
  </code></pre>