question

upsy avatar image
upsy asked

VRM api via axios/ nodejs ? code exemple ?

Hello I'm trying to connect to VRM portal via axios / nodejs / vuejs
but I'cant find exemple of code.
I get the token & userId but after the token no longuer seem valid for other end points ?

when I use token in header with header :

   var headers =
   'Authorization': 'Bearer ' + token
   };

https://vrmapi.victronenergy.com/v2/users/***myUserId****/installations

Apti return 401.

Some ideas/exemples please ? thanks by advance
Yann
my code (login)

const params = {
'username': '******@gmail.com',
'password': '******',
}
const header = {
'Content-Type': 'application/x-www-form-urlencoded'
}

/**
 * call via axios 
 */
 await Axios.post('https://vrmapi.victronenergy.com/v2/auth/login/', params , header).then   ((resp)=>{
 return resp
 /** return 
*
*response": {
    "Token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdkZTcw******************"
    "idUser": *****, // ok
    "verification_mode": "password",
    "verification_sent": false
  
}
*
*
*/

 }).catch((err) => console.log(err.message)); 

 
VRM
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
westcott avatar image
westcott answered ·

Hi Upsy,

This seems to work -

"X-Authorization": "Bearer " + token

Found that by looking in the Victron Node-Red code.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.