jsonwebtoken.sign() fails with expiresIn option set
https://www.npmjs.com/package/jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback
payload could be an object literal, buffer or string. Please note that exp is only set if the payload is an object literal.
Set the payload as an object if you want to be able to set the expiresIn
option
var token = jwt.sign(
{id: accounts[request.headers.login].id}, // object and not string
privateKey,
{expiresIn: '60d'} // added days, default for ex 60 would be ms, you can also provide '1h' etc
)