Skip to content

Commit 09356d0

Browse files
committed
README: access token → api key
1 parent 5ae8b24 commit 09356d0

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A professional, production-ready SDK for integrating with the Keymint API in Pyt
66
- **Type hints**: Full type hint support for better IDE integration and code safety.
77
- **Comprehensive**: Complete API coverage for all Keymint endpoints.
88
- **Consistent error handling**: All API errors are returned as structured objects or exceptions.
9-
- **Security**: Credentials are always loaded from environment variables.
9+
- **Machine Identity**: Built-in utilities for hardware fingerprinting and stable installation IDs.
1010

1111
## Installation
1212
Add the SDK to your project:
@@ -19,29 +19,34 @@ pip install keymint
1919

2020
```python
2121
import os
22-
from keymint import KeyMint
22+
from keymint import KeyMint, identity
2323

24-
access_token = os.environ.get('KEYMINT_ACCESS_TOKEN')
24+
api_key = os.environ.get('KEYMINT_API_KEY')
2525
product_id = os.environ.get('KEYMINT_PRODUCT_ID')
2626

27-
if not access_token or not product_id:
28-
raise ValueError('Please set the KEYMINT_ACCESS_TOKEN and KEYMINT_PRODUCT_ID environment variables.')
27+
if not api_key or not product_id:
28+
raise ValueError('Please set the KEYMINT_API_KEY and KEYMINT_PRODUCT_ID environment variables.')
2929

30-
sdk = KeyMint(access_token)
30+
sdk = KeyMint(api_key)
3131

32-
# Example: Create a key with authorized hosts
32+
# 1. Get a stable, unique ID for this machine
33+
host_id = identity.get_or_create_installation_id()
34+
35+
# 2. Create a key authorized only for this machine
3336
result = sdk.create_key({
3437
'productId': product_id,
35-
'allowedHosts': ['machine-a']
38+
'allowedHosts': [host_id]
3639
})
3740

3841
if result and 'key' in result:
39-
key = result['key']
40-
# ...
42+
print(f"Created Key: {result['key']}")
4143
```
4244

43-
## Error Handling
44-
All SDK methods return a dictionary. If an API call fails, the SDK raises a `KeyMintApiError` exception with `message`, `code`, and `status` attributes.
45+
## Machine Identity
46+
Keymint provides utilities to uniquely identify machines for node-locking:
47+
48+
- `identity.get_or_create_installation_id()`: **Recommended.** Generates a stable UUID anchored to hardware and persists it to `~/.keymint/installation-id`.
49+
- `identity.get_machine_id()`: Generates a SHA-256 fingerprint based on BIOS UUID, OS machine ID, and MAC address.
4550

4651
## API Methods
4752

0 commit comments

Comments
 (0)