I am lost with using HMAC SHA256 for api authentication. This is my first time using it and I'm not sure what I am missing although I suspect it has to do with the timestamp. Can someone please help me identify what it is I am missing?
Everytime I try and make an API call I get a response stating
data: { success: false, error: 'Not logged in: Invalid signature' }
Here are the requirements for making the API call including the HMAC SHA256.
Here is the code I am using currently:
const axios = require('axios');
var forge = require('node-forge');
require('dotenv').config()
// get timestamp
var time = new Date().getTime();
// generate and return hash
function generateHash(plainText,secretKey)
    {
        var hmac = forge.hmac.create();  
            hmac.start('sha256', secretKey);
            hmac.update(plainText);  
            var hashText = hmac.digest().toHex();  
            return hashText
        }      
// set axios config
var config = {
    url:"https://ftx.us/api/wallet/all_balances",
    
    method:"GET",
    
    headers :{
        "FTXUS-KEY":process.env.FTX_API_KEY,
        "FTXUS-TS":time,
        "FTXUS-SIGN":generateHash(`${new Date()}${"GET"}${"/wallet/all_balances"}`,process.env.FTX_API_SECRET)
    }
}
axios(config)
.then(response => {
    console.log(response.data)
}).catch(function (error) {
    console.log(error);
})
