ux4iot
Search…
Node.js
The Node Admin SDK can be found on GitHub.
First, add the dependency:
NPM
Yarn
1
npm install ux4iot-admin-node
Copied!
1
yarn add ux4iot-admin-node
Copied!
Initialize the SDK using the connection string. You can retrieve the connection string from the Azure portal.
1
const Ux4iotAdmin = require('ux4iot-admin');
2
const sdk = new Ux4iotAdmin({
3
connectionString: "HostName=...;Key=secret";
4
});
Copied!
Now you can whitelist grant requests using:
1
sdk.grant(grantRequest);
Copied!
Usually, the grantRequest will be exactly identical to the body received by the custom security backend. In the security backend, you merely decide which grant requests to forward and which not to forward.
If you want to revoke the grant at a later point in time, you can do this using:
1
sdk.revokeGrant({
2
sessionId: "ijfoewio22490320",
3
deviceId: "d123",
4
grantType: "subscribeToTelemetry"
5
});
Copied!
You can revoke all grants for a session with this:
1
sdk.revokeSession("ijfoewio22490320");
Copied!
You can even revoke all sessions:
1
sdk.revokeAll();
Copied!
Copy link