BT
x Share your thoughts on trends and content!

Apple Open CloudKit to Server-to-Server Requests

by on Feb 09, 2016 |

Apple has recently announced that CloudKit, OS X and iOS framework that provides access to Apple’s cloud platform, is now open to server-to-server web requests. This removes the previous restriction that limited access to the CloudKit public database only from iOS and Mac apps and through Apple’s web site.

CloudKit server-to-server requests adds to the previously existing features that allowed developers to providing a web interface so users could access their iCloud data. Server-to-server requests aim to give access to iCloud public database and could partially provide an alternative to Parse DBaaS, whose shutdown has been recently announced.

In order to read or write to the public CloudKit database from a server-side process or script, developers need to first generate a key pair using OpenSSL:

openssl ecparam -name prime256v1 -genkey -noout -out eckey.pem

Then, they should associate the public key with a CloudKit container by going to the CloudKit dashboard and then to API Access/Server-to-Server Keys. Once the public key has been stored, a keyID is generated that shall be included in the subpath of web services requests. Apple provides some JavaScript sample code that shows how developers can use the new method to authenticate against CloudKit. In particular, developers should build a string that concatenates three parameters:

[Current date]:[Request body]:[Web Service URL]

to be used in the request, as the following Apple-provided curl example shows:

curl -X POST -H "content-type: text/plain" -H "X-Apple-CloudKit-Request-KeyID: [keyID]” -H "X-Apple-CloudKit-Request-ISO8601Date: [date]" -H "X-Apple-CloudKit-Request-SignatureV1: [signature]" -d '{"users":[{"emailAddress":"[user email]"}]}' https://api.apple-cloudkit.com/database/1/[container ID]/development/public/users/lookup/email

Several users on Stack Overflow have provided alternative implementation in JavaScript, PHP, and Python.

CloudKit provides several services to developers, including authentication, a private and a public database, and structured, e.g. plist-based, asset storage.

Rate this Article

Relevance
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
General Feedback
Bugs
Advertising
Editorial
Marketing
InfoQ.com and all content copyright © 2006-2016 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT

We notice you're using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.