更新令牌
使用 InfluxDB 用户界面 (UI) 更新 API 令牌的描述和状态。
在 InfluxDB UI 中更新令牌
- 在左侧导航菜单中,选择 数据 (加载数据) > API 令牌。
- 点击 描述 列中令牌名称旁边的铅笔图标 。
- 更新令牌描述,然后点击其他任何位置以保存。
在 InfluxDB UI 中启用或禁用令牌
- 在左侧导航菜单中,选择 数据 (加载数据) > API 令牌。
- 点击 状态 开关。
使用 influx CLI 启用令牌
使用 influx auth active
命令 激活令牌。
此命令需要授权 ID,该 ID 可在 influx auth find
的输出中找到。
# Syntax
influx auth active -i <auth-id>
# Example
influx auth active -i 0804f74142bbf000
要获取令牌的当前状态,请使用 influx auth list
命令 的 JSON 输出。
influx auth find --json
使用 influx CLI 禁用令牌
使用 influx auth inactive
命令 停用令牌。
此命令需要授权 ID,该 ID 可在 influx auth find
的输出中找到。
# Syntax
influx auth inactive -i <auth-id>
# Example
influx auth inactive -i 0804f74142bbf000
要获取令牌的当前状态,请使用 influx auth list
命令 的 JSON 输出。
influx auth find --json
使用 InfluxDB API 更新令牌
使用 /api/v2/authorizations
InfluxDB API 端点更新令牌的描述和状态。
PATCH http://localhost:8086/api/v2/authorizations/AUTH_ID
在你的请求中包含以下内容
要求 | 包含方式 |
---|---|
具有 write: authorizations 权限的 API 令牌 | 使用 Authorization: Token YOUR_API_TOKEN 标头。 |
授权 ID | URL 路径参数。 |
描述和/或状态 | 在请求正文中作为 description , status 传递。 |
禁用令牌
# Update the description and status of the first authorization listed for the user.
curl --request GET \
"http://localhost:8086/api/v2/authorizations?user=user2" \
--header "Authorization: Token ${INFLUX_TOKEN}" \
--header 'Content-type: application/json' \
| jq .authorizations[0].id \
| xargs -I authid curl --request PATCH \
http://localhost:8086/api/v2/authorizations/authid \
--header "Authorization: Token ${INFLUX_TOKEN}" \
--header 'Content-type: application/json' \
--data '{
"description": "deactivated_auth",
"status": "inactive"
}' | jq .
此页是否对您有帮助?
感谢您的反馈!