python - Duo API Bash 调用

标签 python bash shell api curl

我正在尝试使用 Curl 通过 DUO API 执行调用。

我试着在这里查看他们的文档:https://duo.com/docs/adminapi#authentication

文档说将凭据作为请求的 HMAC key 传递,但现在确定如何实现它。

这是我到目前为止得到的:

curl --request GET \
     --header 'Authorization: Basic 'Integration key:Secret key'' \
     --header "Content-Type: application/x-www-form-urlencoded" \
     "https://api-12345678.duosecurity.com/auth/v2/check"

哪个返回

{"code": 40101, "message": "Missing request credentials", "stat": "FAIL"}

有人能为我指出 Bash 中的示例的正确方向吗?如果不是在 Python 中。

最佳答案

首先,您的请求格式似乎不正确,因为 Integration key:Secret key'' 在 header 之外(查看问题中突出显示语法的方式)。

尝试:

curl --request GET \
     --header 'Authorization: Basic' \
     --header 'Integration key: Secret key' \
     --header 'Date: Tue, 21 Aug 2012 17:29:18 -0000' \
     --header "Content-Type: application/x-www-form-urlencoded" \
     "https://api-12345678.duosecurity.com/auth/v2/check"

Integration key 这样的标题名称带有空格和小写字母的情况并不常见,因此您可能需要尝试变体,例如 Integration-Key

401xx系列错误mean:

401 The “Authorization”, “Date”, and/or “Content-Type” headers were missing or invalid.

您需要添加 authenticator 所需的缺少的 Date header 。

关于python - Duo API Bash 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47166077/

相关文章:

python - 导入错误 : cannot import name 'speech_v1p1beta1'

linux - 使用 cron 运行脚本的正确方法?

python - 自动化 shell 脚本登录 vpn 传递 sudo -S

shell - 在 Ubuntu 中嵌套 ${PATH}

bash - 如何使用 netcat 等待开放端口?

python - 尝试将数据插入 SQL 数据库。错误 1046 未选择数据库

python - 请求无法连接到 TLS 服务器

python - Python 3.6 中的 numpy : Importing the multiarray numpy extension module failed

arrays - 在bash中将数组中的一个键关联多个值

linux - 在两个逗号之间抓取数据