title: Can't get HMAC Authentication working with API
body: <p>I'm trying to authenticate using HMAC with the <a href="https://localbitcoins.com/api-docs/" rel="nofollow">LocalBitcoins API</a>.</p>
  
  <p>Here is the authentication written in Python:</p>
  
  <pre><code>  message = str(nonce) + hmac_auth_key + relative_path + get_or_post_params_urlencoded
    signature = hmac.new(hmac_auth_secret, msg=message, digestmod=hashlib.sha256).hexdigest().upper()
  </code></pre>
  
  <p>And the parameters to create the HMAC message:</p>
  
  <pre><code>Nonce. A 63 bit positive integer, for example unix timestamp as milliseconds.
  
  HMAC authentication key. This is the first one of a key/secret pair.
  
  Relative path, for example /api/wallet/.
  
  GET or POST parameters in their URL encoded format, for example foo=bar&amp;baz=quux.
  </code></pre>
  
  <p>Here is how I am building the HMAC:</p>
  
  <pre><code>var milliseconds = (new Date).getTime();
  var key = config.key;
  var secret = config.secret;
  var nonce = milliseconds.toString()
  
  
  var message = nonce + key + 'api/myself';
  
  var hmac_digest = crypto.createHmac("sha256", secret).update(message).digest('hex').toUpperCase();
  </code></pre>
  
  <p>The signature is sent via 3 HTTP Headers. The options for the call to the api/myself method looks like such (using request):</p>
  
  <pre><code>{ url: 'https://localbitcoins.com/api/myself',
    method: 'GET',
    headers:
     { 'Apiauth-Key': 'my api key',
       'Apiauth-Nonce': 1439925212276,
       'Apiauth-Signature': 'the created signature' },
    timeout: 5000 }
  </code></pre>
  
  <p>And the request:</p>
  
  <pre><code>var req = request.get(options, function(error, response, body) {
      console.log(body);
  });
  </code></pre>
  
  <p>But everytime I get the following error message:</p>
  
  <pre><code>{ error:
     { message: 'HMAC authentication key and signature was given, but they are invalid.',
       error_code: 41 } }
  </code></pre>
  
  <p>I've tried lots of different combinations in testing but can't get anything to work. What am I missing?</p>