使用此端点为指定用户创建新 API 密钥。
API 密钥在创建响应中仅显示这一次。它不会再次显示,而且一旦丢失将无法找回。
curl -X POST \
'https://www.digicert.com/services/v2/key/user/{{user_id}}' \
-H 'Content-Type: application/json' \
-H 'X-DC-DEVKEY: {{api_key}}' \
-d '{ "name": "New API Key" }'
import requests
url = "https://www.digicert.com/services/v2/key/user/{{user_id}}"
payload = "{\n \"name\": \"New API Key\"\n}"
headers = {
'X-DC-DEVKEY': "{{api_key}}",
'Content-Type': "application/xml"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://www.digicert.com/services/v2/key/user/{{user_id}}"
payload := strings.NewReader("{\n \"name\": \"New API Key\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DC-DEVKEY", "{{api_key}}")
req.Header.Add("Content-Type", "application/xml")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
var request = require("request");
var options = { method: 'POST',
url: 'https://www.digicert.com/services/v2/key/user/{{user_id}}',
headers:
{ 'Content-Type': 'application/xml',
'X-DC-DEVKEY': '{{api_key}}' },
body: '{\n "name": "New API Key"\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
{
"id": 184,
"api_key": "Aqdgb0p5U153195f22s6pw5cj0mfvp06xg89xw0xhh3zhc2"
}
名称 | 请求/选项 | 类型 | 描述 |
---|---|---|---|
name | 必填 | string | 密钥名称。 |
restricted_to_role_id | 可选 | int |
要限制 API 密钥权限,请指定 API 访问角色 ID。 允许的值: 0 ,100 ,101 ,102 (请参阅词汇表 - API 密钥角色)
|
名称 | 类型 | 描述 |
---|---|---|
id | int | 所创建密钥的唯一标识符。 |
api_key | string | 随机生成的 API 密钥。 |