-
Notifications
You must be signed in to change notification settings - Fork 211
Description
Issue type
- bug
data: [ 'error', 10100, 'apikey: invalid' ] - missing functionality
- performance
- feature request
Hi guys
Brief description
i' am trying my first authentication to log user info in terminal. i have the correct api key but it does not work.
Can someone explain me what i do wrong please? thanks
Steps to reproduce
const { WSv2 } = require('bitfinex-api-node')
const ws = new WSv2({ transform: true })
const crypto = require('crypto-js') // Standard JavaScript cryptography library
const WebSocket = require('ws') // Websocket library for Node
const apiKey = '' // Users API credentials are defined here
const apiSecret = ''
const authNonce = Date.now() * 1000 // Generate an ever increasing, single use value. (a timestamp satisfies this criteria)
const authPayload = 'AUTH' + authNonce // Compile the authentication payload, this is simply the string 'AUTH' prepended to the nonce value
const authSig = crypto.HmacSHA384(authPayload, apiSecret).toString(crypto.enc.Hex) // The authentication payload is hashed using the private key, the resulting hash is output as a hexadecimal string
const payload = {
apiKey, //API key
authSig, //Authentication Sig
authNonce,
authPayload,
event: 'auth', // The connection event, will always equal 'auth'
//dms: 4, // Optional Dead-Man-Switch flag to cancel all orders when socket is closed
//filter: [] // Optional filter for the account info received (default = everything)
}
const wss = new WebSocket('wss://api.bitfinex.com/ws/2') // Create new Websocket
wss.on('open', () => wss.send(JSON.stringify(payload)))
wss.on('message', (msg) => { // The 'message' event is called whenever the ws recieves ANY message
let response = JSON.parse(msg)
console.log(msg)
})
const apiPath = 'v2/auth/r/info/user'
const axios = require('axios');
axios(https://api.bitfinex.com/${apiPath}
, {
method: 'POST',
body: JSON.stringify({
}),
headers: {
/* auth headers */
}
})
.then(res => res.json())
.then(json => console.log(json))
.catch(err => {
console.log(err)
})-