CloudKit JS

Hi all!


I though I'd experiment a bit with CloudKit and the new javascript client. This is what I've done:

  • Obtained the API key and container identifier
  • Set up the correct records as required


However I can't get it to work, here's what I've tried:

  • Run it locally
  • Run it locally with SSL enabled
  • Run it on server


I get is the following error when trying to authenticate:


[Error] Failed to load resource: the server responded with a status of 421 (Bad Request) (current, line 0)


When I run Apples demo (the sample project), it works:

https://developer.apple.com/icloud/index.html


Have anyone got it to work?

I have the same issue, additionally I get:


[Error] Refused to get unsafe header "X-Apple-Request-UUID"
  onload (ck-auth, line 260)
[Error] Refused to get unsafe header "X-Apple-Jingle-Correlation-Key"
  onload (ck-auth, line 261)


when trying to log in.

As can be seen here:


http://stackoverflow.com/questions/30878380/failed-to-load-resource-the-server-responded-with-a-status-of-421-bad-request


Apparently localhost is not accepted as a source domain for CloudKit (which kind of makes sense). You will have to host the files on a server which is not localhost.

I'm running on a localhost installation and can flawlessly sign in and out and work with CloudKit JS.

Did you disallow 'Any Region' in your API Token?


Some stupid question: Did you set up the correct sign-in and sign-out div elements?

I only get HTTP:421 when I'm not signed in and the 'Sign in with Apple ID' Button appears.


I'm not sure if manual sign–in works with CloudKit JS. You should provide the needed buttons before setting up the container so clicking the sign–in button should handle all you need.

<div id="apple-sign-in-button"></div>
<div id="apple-sign-out-button"></div>
Accepted Answer

I got it to work now, the problem was that I wasn't running on port 80.

CloudKit JS
 
 
Q