requests-cloudkit 1.0.1

Creator: railscoder56

Last updated:

0 purchases

requests-cloudkit 1.0.1 Image
requests-cloudkit 1.0.1 Images

Languages

Categories

Add to Cart

Description:

requestscloudkit 1.0.1

|image0| |image1||CI Status| |Version|This project provides an authentication handler for Apple’s CloudKitserver-to-server API for the requests Python library. In English, thismeans that this library lets you interact with CloudKit with Python in aserver environment. It just has twodependencies–\ `requests <https://github.com/kennethreitz/requests>`__and python-ecdsa–and lets you skip all of the dull and boringcryptographic signing steps when authenticating with CloudKit on yourown. While the underlying code is pretty straightforward, there was nocorrect code sample available online that described how to do this–butnow there is!Installation------------requests-cloudkit is available for download through the Python PackageIndex (PyPi). You can install it right away using pip or easy_install... code:: bash pip install requests-cloudkitUsage-----requests-cloudkit provides an authentication handler that can be passeddirectly to the requests library to authenticate requests to theCloudKit API. Before working with the CloudKit server-to-server API,you’ll first need to follow Apple’s instructions to generate acertificate and a server-to-server key (see `Accessing CloudKit Using aServer-to-ServerKey <https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/SettingUpWebServices/SettingUpWebServices.html#//apple_ref/doc/uid/TP40015240-CH24-SW6>`__).Once you have these values, just plug them into a CloudKitAuth object,which you can use with requests to interface with CloudKit. E.g.:.. code:: pycon >>> 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)Using Requests-CloudKit with RestMapper---------------------------------------requests-cloudkit can also be used with`python-restmapper <https://github.com/lionheart/python-restmapper>`__to integrate directly with the CloudKit API... code:: pycon >>> CloudKit = restmapper.RestMapper("https://api.apple-cloudkit.com/database/[version]/[container]/[environment]/")Instantiate a cloudkit instance using your CloudKit server-to-server keyID and provide the path to the private key file... code:: pycon >>> cloudkit = CloudKit(auth=CloudKitAuth(key_id=YOUR_KEY_ID, key_file_name=YOUR_KEY_FILE))Now, you can start making requests to the CloudKit API using a niceattribute syntax... code:: pycon >>> response = cloudkit.public.zones.list()The above will hithttps://api.apple-cloudkit.com/database/[version]/[container]/[environment]/public/zones/list.If you want to pass in body data for a POST, provide a single argumentto the call to the API, and specify “POST” as the first attribute (note:this argument expects a *str* value, so if you want to pass JSON, use``json.dumps`` to encode it into a string). I.e... code:: pycon >>> cloudkit.POST.my.request(data)Or:.. code:: pycon >>> cloudkit.POST.my.request(json.dumps(json_payload))For the full list of CloudKit Server-to-Server API capabilities,reference `Apple’s developerdocumentation <https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40015240-CH1-SW1>`__.Support-------If you like this library, or need help implementing it, just send us anemail: [email protected]... _license-licenselicense-imagelicense-url:License |License|-----------------Apache License, Version 2.0. See `LICENSE <license-url>`__ for details... raw:: html <!-- .. |downloads| image:: https://img.shields.io/pypi/dm/requests-cloudkit.svg?style=flat .. _downloads: https://pypi.python.org/pypi/requests-cloudkit -->.. |image0| image:: meta/repo-banner.png.. |image1| image:: meta/repo-banner-bottom.png :target: https://github.com/lionheart/requests-cloudkit/blob/master/https://lionheartsw.com/.. |CI Status| image:: https://img.shields.io/travis/lionheart/requests-cloudkit.svg?style=flat :target: https://github.com/lionheart/requests-cloudkit/blob/master/https://travis-ci.org/lionheart/requests-cloudkit.py.. |Version| image:: https://img.shields.io/pypi/v/requests-cloudkit.svg?style=flat :target: https://github.com/lionheart/requests-cloudkit/blob/master/https://pypi.python.org/pypi/requests-cloudkit.. |License| image:: http://img.shields.io/pypi/l/requests-cloudkit.svg?style=flat :target: https://github.com/lionheart/requests-cloudkit/blob/master/LICENSE

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.