CloudKit Server-to-Server authentication

后端 未结 6 1727
慢半拍i
慢半拍i 2020-12-07 19:11

Apple published a new method to authenticate against CloudKit, server-to-server. https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/CloudKit

6条回答
  •  囚心锁ツ
    2020-12-07 19:47

    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.

提交回复
热议问题