Izzuddin Cheras
Izzuddin Cheras

Reputation: 237

cloudkit JS API authentication

Ok, I have a working cloudkit container that I am currently using as a database for my app. Now I want to try using the cloudkit API service. In the API access section, I just add a new token. this is the overview of my simple set up: enter image description here

I tried using Postman to make one POST call, trying to see if my structure of my API call is right. my cloudkit container name is iCloudkit.izzuddin.CoffeeApp, and the records name is Cafe, so this is how I create the api call:

cloudkit.com/database/1/iCloud.izzuddin.CoffeeApp.Cafe/-development/public/records/modify?NewToken=031c663b3314f16ff3ee04719894b6f4e17132ad315eae27fa3e4374fd0b4e81

this is the returned value:

{ "uuid": "737d61ec-a668-4386-9512-b2ec05a8a394", "serverErrorCode": "AUTHENTICATION_FAILED", "reason": "no auth method found" }

Can anybody who have experience explain how to structure the api call? thanks in advance.

Upvotes: 2

Views: 1051

Answers (2)

marknote
marknote

Reputation: 1077

CloudKit Web Service needs not only your API token, but also needs [Web Auth Token], which represents the users.

Upvotes: 0

Max Gunther
Max Gunther

Reputation: 306

Try:

https://api.apple-cloudkit.com/database/1/iCloud.izzuddin.CoffeeApp.Cafe/development/public/records/modify?ckAPIToken=031c663b3314f16ff3ee04719894b6f4e17132ad315eae27fa3e4374fd0b4e81

This should return 421 response AUTHENTICATION_REQUIRED with a redirectURL which you can use for signing in.

The next steps depend on what kind of app (web app / server to server / native) you want to build.

Upvotes: 1

Related Questions