Apple published a new method to authenticate against CloudKit, server-to-server. https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/CloudKit
I had the same problem and ended up writing a library that works with python-requests to interface with the CloudKit API in Python.
pip install requests-cloudkit
After it's installed, just import the authentication handler (CloudKitAuth
) and use it directly with requests. It will transparently authenticate any request you make to the CloudKit API.
>>> import requests
>>> from requests_cloudkit import CloudKitAuth
>>> auth = CloudKitAuth(key_id=YOUR_KEY_ID, key_file_name=YOUR_PRIVATE_KEY_PATH)
>>> requests.get("https://api.apple-cloudkit.com/database/[version]/[container]/[environment]/public/zones/list", auth=auth)
The GitHub project is available at https://github.com/lionheart/requests-cloudkit if you'd like to contribute or report an issue.