所有用户全局密钥访问无效

今天刚注意到这个问题。

所有用户生成具有全局范围的 API 密钥后,更新主题会导致 invalid_access 错误:

curl --location --request PUT 'https://example.com/t/-/365.json' \
--header 'Api-User: system' \
--header 'Api-Key: ***' \
--header 'Content-Type: application/json' \
--data-raw '{
    "tags": ["awesome-tag"]
}'
{
    "errors": [
        "您无权查看请求的资源。API 用户名或密钥无效。"
    ],
    "error_type": "invalid_access"
}

但是,如果为用户 system 生成全局 API 密钥,则请求可以成功:相同的请求,不同的密钥。

curl --location --request PUT 'https://example.com/t/-/365.json' \
--header 'Api-User: system' \
--header 'Api-Key: DIFFERENT_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "tags": ["awesome-tag"]
}'
{
    "basic_topic": {
        "id": 365,
        "title": "Test topic",
        "fancy_title": "Test topic",
        "slug": "test-topic",
        "posts_count": 6
    }
}

这里应该是 Api-Username,而不是 Api-User

此标头仅用于“所有用户”API 密钥,这就是为什么当你将密钥限定到特定用户时它能正常工作。

啊,好的,这是最近改的吗?因为我记得表头是 Api-User

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.