我刚刚开始构建一个web应用程序,由于某种原因,我不得不使用CloudKit和它的数据库作为我的后端。
我尝试了一个非常愚蠢的数据库查询,并打算在前端查看结果。下面是我的代码:
CloudKit.configure({
containers: [{
containerIdentifier: my identifier,
apiToken: my api token,
environment: 'development'
}]
});
var container = CloudKit.getDefaultContainer();
var DB = container.publicCloudDatabase;
var query = {recordType : 'Request'};
DB.performQuery(query).then(function(response){
if (response.hasErrors) {
throw response.errors[0];
} else {
console.log(response);
}
});
但是,我一直收到这个authentication_failed错误:
cloudkit.js:3 Uncaught (in promise) t {_ckErrorCode: "AUTHENTICATION_FAILED", _uuid: "4ef8ba12-eb00-408f-9a1c-6e8b4de84ec8", _reason: "no auth method found", _serverErrorCode: "AUTHENTICATION_FAILED", _extensionErrorCode: undefined…}
我尝试使用相同的代码来获取记录,它工作得很好。那么这个错误是由未登录的用户引起的吗?如果是,CloudKit仪表板中是否有任何配置允许来自特定网址的用户在不登录的情况下查询数据库?谢谢!
发布于 2017-01-29 08:21:43
检查containerIdentifier值。当我使用API Token的标识符名称而不是从应用程序名称生成的iCloud标识符时,我遇到了类似的问题。您还可以通过链接使用CloudKit目录进行测试来验证令牌
https://stackoverflow.com/questions/39604313
复制相似问题