title: Binance API Signature with Google Scripts
body: <p>I am stuck on how to correctlly include the signitue into my get command based off of the <a href="https://www.binance.com/restapipub.html" rel="nofollow noreferrer">Binance API</a> within Google Scripts. What it states is </p>
  
  <blockquote>
    <p>SIGNED endpoints require an additional parameter, signature, to be sent in the query string or request body.
    Endpoints use HMAC SHA256 signatures. The HMAC SHA256 signature is a keyed HMAC SHA256 operation. Use your secretKey as the key and totalParams as the value for the HMAC operation.
    The signature is not case sensitive.
    totalParams is defined as the query string concatenated with the request body.</p>
  </blockquote>
  
  <p>What I have is:</p>
  
  <pre><code>function BinanceTrades() {
    var curTime = Number(new Date().getTime()).toFixed(0)
    var sKey = Utilities.computeHmacSha256Signature('symbol=LTCBTC&amp;timestamp=' + curTime, '**mySeceretKey**');
    Logger.log(sKey)
    var headers = {'X-MBX-APIKEY': '**myKey**'}
    var data = UrlFetchApp.fetch("https://api.binance.com/api/v3/allOrders?signature=" + sKey + "&amp;symbol=LTCBTC&amp;timestamp=" + curTime, {'headers' : headers})
    Logger.log(data)
  }
  </code></pre>
  
  <p>and the error I get is:</p>
  
  <blockquote>
    <p>{"code":-1100,"msg":"Illegal characters found in parameter 'signature'; legal range is '^[A-Fa-f0-9]{64}$'."}</p>
  </blockquote>
  
  <p>I am unsure of how to compute the HMAC SHA256 correctly and incorporate the totalParams.</p>
  
  <p>My previous post was <a href="https://stackoverflow.com/questions/48178861/binance-api-with-google-script">this.</a></p>