xq.api.subscription package
Submodules
xq.api.subscription.authentication module
- xq.api.subscription.authentication.code_validate(api, pin: int)
validate the provided 2FA pin https://xq.stoplight.io/docs/xqmsg/b3A6NDA5MjQ1MjM-validate-access-request-with-a-pin
- Parameters:
api (XQAPI) – XQAPI instance
pin (int) – 2FA code
- Raises:
XQException – invalid pin
- Returns:
isvalid? boolean response
- Return type:
bool
- xq.api.subscription.authentication.exchange_key(api, business_id: str | None = None, selector: bool = False)
exchange pre-auth token for an access token, and update headers accordingly https://xq.stoplight.io/docs/xqmsg/b3A6NDA5Mzc1NjA-exchange-for-access-token
- Parameters:
api (XQAPI) – XQAPI instance
- Raises:
XQException – key exchange failure
- Returns:
success? boolean
- Return type:
bool
- xq.api.subscription.authentication.validate_api_key(api)
static method for validating provided API keys https://xq.stoplight.io/docs/xqmsg/b3A6NDExNDU1MDg-check-if-valid-api-key
- Parameters:
api (XQAPI) – XQAPI instance
- Raises:
SDKConfigurationException – exception for invalid keys
SDKConfigurationException – exception for http errors
- Returns:
api response
- Return type:
str OR json
xq.api.subscription.key_management module
- xq.api.subscription.key_management.create_and_store_packet(api, recipients: list, expires_hours: int = 24, key: bytes | None = None, type: int | str = 'msg', subject: str | None = None, labels: list | None = None)
creates an encrypted packet from a secret key https://xq.stoplight.io/docs/xqmsg/1f9bc1713a7cd-create-and-save-a-new-key-packet
- Parameters:
api (XQAPI) – XQAPI instance
recipients (list) – list of emails to grant access to
expires_hours (int, optional) – packet validation time in hours, defaults to 24
key (bytes, optional) – secret key to encrypt, defaults to None
- Raises:
XQException – failed packet creation
- Returns:
api response, the encrypted packet
- Return type:
text
- xq.api.subscription.key_management.create_and_store_packets(api, recipients: list, expires_hours: int = 24, keys: list | None = None, type: int = 5, subject: str | None = None, meta: str | None = None)
creates an encrypted packet from a secret key https://xq.stoplight.io/docs/xqmsg/1f9bc1713a7cd-create-and-save-a-new-key-packet
- Parameters:
api (XQAPI) – XQAPI instance
recipients (list) – list of emails to grant access to
expires_hours (int, optional) – packet validation time in hours, defaults to 24
key (bytes, optional) – secret key to encrypt, defaults to None
- Raises:
XQException – failed packet creation
- Returns:
api response, the encrypted packet
- Return type:
text
- xq.api.subscription.key_management.create_packet(api, recipients: list, expires_hours: int = 24, key: bytes | None = None, type: int = 3, subject: str | None = None)
creates an encrypted packet from a secret key https://xq.stoplight.io/docs/xqmsg/b3A6NDA5MDQ5MTY-create-a-new-key-packet
- Parameters:
api (XQAPI) – XQAPI instance
recipients (list) – list of emails to grant access to
expires_hours (int, optional) – packet validation time in hours, defaults to 24
key (bytes, optional) – secret key to encrypt, defaults to None
- Raises:
XQException – failed packet creation
- Returns:
api response, the encrypted packet
- Return type:
text
xq.api.subscription.user_management module
- xq.api.subscription.user_management.authorize_alias(api, user_email: str, firstName: str, lastName: str)
request an access token for the given user information https://subscription.xqmsg.net/v2/authorizealias
- Parameters:
api (XQAPI) – XQAPI instance
user_email (str) – email address of user requesting access token
firstName (str) – first name of user
lastName (str) – last name of user
- Returns:
access token
- Return type:
str
- xq.api.subscription.user_management.authorize_device(api, device: str, business_id: str | None = None)
request pre-auth token for a given email address, this token will need to be exchanged for an access token https://xq.stoplight.io/docs/xqmsg/b3A6NDA5MDAxNDE-request-access-for-a-user
- Parameters:
api (XQAPI) – XQAPI instance
user_email (str) – device name requesting access token
newsletter (bool, optional) – subscribe to newsletter, defaults to False
notifications (int, optional) – notification level: 0 = No Notifications, 1 = Receive Usage Reports, 2 = Receive Tutorials, 3 = Receive Both, defaults to 0
- Returns:
pre-aut token, which can be exchanged for an access token
- Return type:
str
- xq.api.subscription.user_management.authorize_device_cert(api, cert_id: int, cert_file_path: str, transport_key_file_path: str, private_key_file_path: str, device_name: str = 'Device', announce: bool = True)
Authorize a device using an XQ certificate and transport key, returning an access token.
- Parameters:
api (XQAPI) – XQ API client instance
cert_id (int) – Certificate identifier issued for the device/tenant
cert_file_path (str) – Path to the client certificate (client.crt)
transport_key_file_path (str) – Path to the transport key used to encrypt the request payload (transport.key)
private_key_file_path (str) – Path to the device private key (client.key) used to decrypt the returned token
device_name (str) – Human-readable device name (max 48 characters), defaults to Device
announce (bool, optional) – If True, announce the device to the dashboard after authorization, defaults to True
- Returns:
Access token for subsequent authenticated requests
- Return type:
str
- Raises:
XQException – If files are missing/empty, the server time cannot be fetched, encryption/decryption fails, or the authorization request is rejected
- xq.api.subscription.user_management.authorize_user(api, user_email: str, firstName: str, lastName: str, newsletter=False, notifications=0)
request pre-auth token for a given email address, this token will need to be exchanged for an access token https://xq.stoplight.io/docs/xqmsg/b3A6NDA5MDAxNDE-request-access-for-a-user
- Parameters:
api (XQAPI) – XQAPI instance
user_email (str) – email address of user requesting access token
firstName (str) – first name of user
lastName (str) – last name of user
newsletter (bool, optional) – subscribe to newsletter, defaults to False
notifications (int, optional) – notification level: 0 = No Notifications, 1 = Receive Usage Reports, 2 = Receive Tutorials, 3 = Receive Both, defaults to 0
- Returns:
pre-aut token, which can be exchanged for an access token
- Return type:
str
- xq.api.subscription.user_management.load_file_content(file_path: str) str
Load content from a file