Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

http status code 401 - Bitrue exchange.Cant access via axios.Error 401 unauthorized

I have a problem here. I'm trying to get my account info via Node.js(Axios) But I'm getting this 401 unauthorized error. Can you help me?

Here is the documentation. https://github.com/Bitrue/bitrue-official-api-docs/blob/master/rest-api.md

const axios = require('axios')
const crypto = require('crypto')


const apikey = "461d7cd32bbecb53e1a366f5f178a0edfb403f60f63fc86ad4fd7cf1776f00ef"
const secretKey = "946dab362d2ff1936dc077f100fa5ad791d8dc984c4a0c471256a5c59eaa876a"
const host_Bitrue = "https://www.bitrue.com"

const timestamp = Date.now()
const recvWindow = 5000


const name = crypto.createHmac("sha256", secretKey)
    .update(`timestamp=${timestamp}&recvWindow=${recvWindow}`)
    .digest("hex");

const sending_data = `timestamp=${timestamp}&signature=${name}&recvWindow=${recvWindow}`

console.log(name)
axios.get(host_Bitrue + '/api/v1/account?' + sending_data, {
    headers: {
        "X-MBX-APIKEY": apikey
    }
})
    .then(data => {
        return console.log(data)
    })
    .catch(err => {
        console.log(err)
    })

I need your help. Thank you.

question from:https://stackoverflow.com/questions/66059148/bitrue-exchange-cant-access-via-axios-error-401-unauthorized

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...