Register device
Register device function is used to perform initial device registration which must be then approved by the administrator, or to perform device re-registration using the known public key.
It is available at /register endpoint.
Required parameters:
client_id: unique device IDclient_secret: Dispatcher Paragon Cloud API keyclient_type: one of: printer,chrome_extension,desktop_client,mobile_device,serverresponse_type: must be device_code
Optional parameters:
client_description: client descriptionstate: a nonce valuepublic_key: base64-encoded public keykey_type: public key type, one of: rsa,x509,ed25519
public_key and key_type parameters, combined with HCP-Request-Signature header provide a means how a known, authorized device may automatically re-register itself automatically and securely, even after extended periods of time.
This functionality is optional, but if desired, then both parameters must be filled in.
Public keys must be wrapped into base64 encoding.
Public keys must be encoded in accordance with X.509 encoding standard. The difference between rsa and x509 is that the provided x509 structure contains also certificate fields in addition to the public key, so a certificate can be passed as a public key.
ED25519 key can be provided in both X.509 encoding and in plain encoding (32-byte key).
If HCP-Request-Signature header is present in the request the device re-registration is assumed and registration approval is not required (provided that the signature is correct). If signature header is missing a new device registration is performed.
Return value: Error object if error occurred, DeviceCode object if registration succeeded.
DeviceCode is a JSON object with the following structure:
{
"device_code": "xxx",
"state": "xxx",
"expires_in": nnn
}
Where device_code is a device code which must be used when calling the /token endpoint, state is the nonce passed as a parameter, expires_in indicates the device_code expiration time in seconds.
After registration call is made the client should poll the /token endpoint to exchange the obtained device_code for the device token.