I'm using iCloud as a way to authenticate a user's identity in a Mac app. I use a bit of code to look up the user's recordName
which is a unique string that helps my app know who they are without needing any personal details.
func fetchCloudKitAccessToken(completion: @escaping (_ accessToken: String?, _ error: Error?) -> Void) {
let container = CKContainer(identifier: "iCloud.my.container.here")
container.fetchUserRecordID { (recordID, error) in
let token = recordID?.recordName
completion(token, error)
}
}
This works great on my Mac where Xcode is building the app. But when I move my app binary to other computers (where I am also signed into iCloud), I get this CKError
:
CKError 0x60800024e4f0: "Not Authenticated" (9); "No iCloud account is configured"
But I am definitely signed in to iCloud. Any idea what's going on?