Skip to content

Commit

Permalink
Merge pull request #113 from KeyPJ/cloudflare-use-api-token
Browse files Browse the repository at this point in the history
Cloudflare use api token
  • Loading branch information
NewFuture authored Nov 19, 2019
2 parents becc3e8 + d6bc54e commit 265a1cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ python run.py -c /path/to/config.json

| key | type | required | default | description | tips |
| :----: | :---------: | :------: | :---------: | :--------------: | ----------------------------------------------------------------- |
| id | string ||| api 访问 ID | cloudflare 为邮箱,<br>HE.net 可留空 |
| id | string ||| api 访问 ID | cloudflare 为邮箱(使用api token可为空,但对应的token需要Zone权限),<br>HE.net 可留空 |
| token | string ||| api 授权 token | 也叫 secret key, **反馈粘贴时删除** |
| dns | string | No | `"dnspod"` | dns 服务商 | 阿里`alidns`,<br>dns.com 为`dnscom`,<br>DNSPOD 国际版`dnspod_com`,<br>HE.net 为`he` |
| ipv4 | array | No | `[]` | ipv4 域名列表 |`[]`时,不会获取和更新 IPv4 地址 |
Expand Down
9 changes: 5 additions & 4 deletions dns/cloudflare.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ def request(method, action, param=None, **params):
if params:
action += '?' + urlencode(params)
params = None
conn.request(method, '/client/v4/zones' + action, params,
{"Content-type": "application/json",
"X-Auth-Email": Config.ID,
"X-Auth-Key": Config.TOKEN})
if Config.ID is None:
headers = {"Content-type": "application/json", "Authorization": "Bearer " + Config.TOKEN}
else:
headers = {"Content-type": "application/json", "X-Auth-Email": Config.ID, "X-Auth-Key": Config.TOKEN}
conn.request(method, '/client/v4/zones' + action, params, headers)
response = conn.getresponse()
res = response.read().decode('utf8')
conn.close()
Expand Down
5 changes: 4 additions & 1 deletion schema/v2.8.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
},
"id": {
"$id": "/properties/id",
"type": "string",
"type": [
"string",
"null"
],
"title": "ID or Email",
"description": "DNS服务API认证的ID或者邮箱"
},
Expand Down

0 comments on commit 265a1cd

Please sign in to comment.