Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kojoakyer opened this issue Feb 4, 2023 · 0 comments
Open

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

kojoakyer opened this issue Feb 4, 2023 · 0 comments

Comments

@kojoakyer
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant