...
Info |
---|
|
Manual Instructions
The following steps describe how to create a new user (steps 1-3) and assign / un-assign devices to a user (step 4)
| 2. Open user creation dialog | 3. Set name, email and password and confirm with checkmark If you want to limit the permissions for this user, open the “Permissions” field and:
| 4. To assign / un-assign devices to users, select the user, open device dialog, check / uncheck desired devices
| ||
Implementation Instructions
...
Code Block | ||
---|---|---|
| ||
const TRACCAR_AUTH_TOKEN = 'AUTH_TOKEN_GIVEN_FROM_POWUNITY'; const TRACCAR_API_URL = 'https://traccariot.powunity-staging.com/api'; var name = 'Max Mustermann'; var email = 'max@mustermann.at'; var password = require('crypto').randomBytes(16).toString('hex'); // Authorization token for your management Traccar user var headers = { 'Content-Type': 'application/json', 'authorization': 'Basic ' + TRACCAR_AUTH_TOKEN }; var json = { name, email, password, deviceLimit: -1 }; console.log('Calling traccar API at', TRACCAR_API_URL); request.post({ url: TRACCAR_API_URL + '/users', headers: headers, json: json }, function (err, response, body) { if (err) { console.log('Traccar create user API call returned an error,', err); throw new Error("Error provisioning server resource, please contact support"); } // user created, add sessionToken to user profile if (response.statusCode === 200) { console.log('New traccar password has been set'); return; } console.log('Traccar returned an unknown error. Body: ' + body); throw new Error("Internal error provisioning your account, please contact support"); }); |
...