Skip to content

bug: Signature for this request is not valid. #496

Description

@kojoakyer

Short Description:

  • im nit able to fetch data form binance api, i have set everything right but i keep getting Signature for this request is not valid.

var apiSecret = process.env.SECRET_KEY

const getParameters = async ()=>{
const response = await fetch('https://api.binance.com/api/v3/time',{
headers:{
"X-MBX-APIKEY":process.env.API_KEY
}
})
const {serverTime}= await response.json()
const query_string = timestamp=${serverTime};
const signature = crypto
.createHmac('sha256', apiSecret)
.update(query_string)
.digest('hex')

console.log(serverTime);
console.log(signature);

return {serverTime,signature}

}

try{
const {serverTime,signature}= await getParameters()

    const response = await fetch(`https://api.binance.com/api/v3/order?symbol=${base}&timestamp=${serverTime}&signature=${signature}`,{
        headers:{
            "X-MBX-APIKEY":process.env.API_KEY,
            "signature":signature
        }
    })
    .then((response) => response.json())
    .then((data) => console.log(data));
    // console.log(response);
    res.status(200).json(response)
  • windows

nodejs version:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions