delian / node-unifiapi

UniFi API ported to Node.JS
GNU General Public License v3.0
49 stars 19 forks source link

Login problem to the unifi api - voucher creation example ? #22

Open Netoperz opened 5 years ago

Netoperz commented 5 years ago

Hello,

I'm looking for example and explanation how to use :

https://github.com/delian/node-unifiapi

I have some AC-Pro aps, and cloudkey G2. i have configured the key, included the aps, and turned on the portal (for voucher auth)

Now in my web app i need to create vouchers using cloud api. That my app running on my server (that is on remote network, could generate the voucher, and this voucher would be available on the remote network where cloudkey g2 is.

I have connected the cloudkey to the ubnt cloud account and i can manage it , add voucher and everything works.

The problem is with using that nodejs api.

let cloud = require('node-unifiapi/cloudapi'); let r = cloud({ deviceId: '801bb78e12c80000000001a22aea000000000203c905000000066660aaaa', // The cloud id of the device username: 'clouduser', password: 'cloudpass', // debug: true, // More debug of the API (uses the debug module) // debugNet: true // Debug of the network requests }); r.api.stat_sessions() .then((data) => { console.log('Stat sessions', data); return r.api.stat_allusers(); }) .then((data) => { console.log('AP data', data); }) .catch((err) => { console.log('Error', err); }) questions:

do I have to use the device ID from the website url ? or is it possible just to use macadress ? username is username that i log in to my ubnt account ? as above the ubnt password ? site is it shortsite name or the name shown in the website ? If someone has got working code example that connects to account, runst auth, and calls the api for voucher generation, than i would be very happy to have a look on that, i do not have much expierience, and working example would be perfect to see.

David-Shayne commented 3 years ago

Hey, ever figure out what the id params are? Have no idea how to get the "cloud id"