【发布时间】:2025-12-13 11:25:02
【问题描述】:
范围键如何用于写操作?
当我尝试使用(范围)写入密钥时,API 响应 401 Unauthorized; “主写密钥”就像一个魅力。使用范围键进行读取操作也可以。
我假设我选择的过滤器等没有成功,但我在the documentation 中找不到任何关于范围键如何为write 操作工作的详细信息。
(对于上下文,我正在努力约束范围键以强制执行某些参数值。本质上,使用范围键将集合“分片”到给定键上,以便多个租户可以写入同一个集合,而不是能够伪造彼此的价值观。)
我使用如下过滤器:
{
"filters": [
{
"property_name": "whatever",
"operator": "eq",
"property_value": "client value"
}
],
"allowed_operations": ["write"]
}
我使用 .net SDK 创建范围密钥,然后可以通过解密密钥来验证过滤器值。它将在 Web 应用程序上使用,因此使用 Keen IO JS library,类似于:
var client = new Keen({
projectId: "…",
writeKey: "…", // <- generated scoped write key goes here
readKey: "…",
protocol: "https",
host: "api.keen.io/3.0",
requestType: "jsonp"
});
client.addEvent("my-collection", { /* … */ }, function (err, res) { /* … */ });
Keen.IO 上的范围写入的 SOP 是什么?
【问题讨论】:
标签: javascript c# keen-io