Python Hardware (Device) IDs

This library provides preconfigured hardware identity providers:

  • HardwareIdProvider (default)

  • PlatformIdProvider

  • HardwareIdProviderSource (recommended)

You can set the desired hardware identity provider when initializing the APIClient:

example.py
from licensespring.hardware import PlatformIdProvider

api_client = APIClient(api_key="_your_api_key_", shared_key="_your_shared_key_", hardware_id_provider=PlatformIdProvider)

It also supports their customization and creation of your own hardware id provider.

circle-exclamation

HardwareIdProvider

Uses uuid.getnode()arrow-up-right to generate unique ID per device as described:

Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with the multicast bit (least significant bit of the first octet) set to 1 as recommended in RFC 4122. “Hardware address” means the MAC address of a network interface. On a machine with multiple network interfaces, universally administered MAC addresses (i.e. where the second least significant bit of the first octet is unset) will be preferred over locally administered MAC addresses, but with no other ordering guarantees.

All of the methods exposed by HardwareIdProvider:

hardware_id_provider.py
class HardwareIdProvider:
    def get_id(self):
        return str(uuid.getnode())

    def get_os_ver(self):
        return platform.platform()

    def get_hostname(self):
        return platform.node()

    def get_ip(self):
        return socket.gethostbyname(self.get_hostname())

    def get_is_vm(self):
        return False

    def get_vm_info(self):
        return None

    def get_mac_address(self):
        return ":".join(("%012X" % uuid.getnode())[i : i + 2] for i in range(0, 12, 2))

    def get_request_id(self):
        return str(uuid.uuid4())

HardwareIdProviderSource

Utilizes a proprietary in-house algorithmarrow-up-right for our SDKs

Customization

Extend any of the preconfigured hardware identity providers, overwrite the methods you want and provide it when initializing the APIClient:

Was this helpful?