title: Keep getting Timestamp error on Coinbase API Call
body: <p>I'm trying to connect my google sheet to Coinbase API using apps script. When I try to use the authentication with my keys, I keep getting the same error {"errors":[{"id":"authentication_error","message":"invalid timestamp"}]} code 401.</p>
  
  <p>I try to check the time difference between my request and Coinbase server (to see if it is more than 30 seconds) and it doesn't. (1589465439 (mine) / 1589465464 (server) ).</p>
  
  <p>so what can be wrong.</p>
  
  <p>my code:</p>
  
  <pre><code> var timestamp = Math.floor(Date.now() / 1000) + 15;
  
    Logger.log(timestamp);
  
    var req = {
      method: 'GET',
      path: '/v2/accounts',
      body: ''
    };
  
    var message = timestamp + req.method + req.path + req.body;
    var secret = Utilities.base64Decode(apiKey);
    secret = Utilities.newBlob(secret).getDataAsString();
  
    //create a hexedecimal encoded SHA256 signature of the message
    var hmac = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_256, message, secret);
    var signature = Utilities.base64Encode(hmac);
  
    Logger.log(signature);
  
    var signatureStr = '';
      for (i = 0; i &lt; signature.length; i++) {
        var byte = signature[i];
        if (byte &lt; 0)
          byte += 256;
        var byteStr = byte.toString(16);
        // Ensure we have 2 chars in our byte, pad with 0
        if (byteStr.length == 1) byteStr = '0'+byteStr;
        signatureStr += byteStr;
      }  
  
  
    Logger.log(signatureStr);
  
    var options = {
      baseUrl: 'https://api.coinbase.com/',
      url: req.path,
      method: req.method,
      headers: {
          'CB-ACCESS-SIGN': signatureStr,
          'CB-ACCESS-TIMESTAMP': timestamp,
          'CB-ACCESS-KEY': apiKey
      }
    };
  
  
  
    var response = UrlFetchApp.fetch("https://api.coinbase.com/v2/accounts", options);
  </code></pre>
  
  <p>Thanks</p>