Tokens
For integration with external applications, it may be necessary for a third-party application to validate the identity of a device. To this end, Nexigon Hub can issue device tokens which can then be used to validate the identity of a device via Nexigonโs API.
Assume you have a custom application (Your App) running on devices connected to some backend (Your Backend) and would like to link the device to a user account in your application and backend. To associate a device with a user account in your app and backend, the app will request a device token from Nexigon Agent. It will then send this token to your backend. The backend will validate the token by sending it to Nexigon Hub. When the validation is successful, Nexigon Hub will return the device id. You can then store this device id in your backend, e.g., to establish a permanent association between the user and their device.
sequenceDiagram
participant Agent as Nexigon Agent
participant App as Your App (Device)
participant Backend as Your Backend
participant Hub as Nexigon Hub
App->>Agent: issue device token
Agent->>Hub: issue device token
Hub->>Agent: device token
Agent->>App: device token
App->>Backend: connect device (device token)
Backend->>Hub: validate (device token)
Hub->>Backend: ok (device id)
Backend->>App: device connected
To issue a device token, run:
nexigon-agent device tokens issue
By default, device tokens are valid for 10 minutes.
You can also attach specific claims to the token and change its validity period:
Issue a device token
Usage: nexigon-agent device tokens issue [OPTIONS]
Options:
--valid-for <VALID_FOR> Seconds for which the token should be valid
--claims <CLAIMS> Additional JSON claims to attach to the token
-h, --help Print help