curl: 请求缺少身份验证 header - 那里有身份验证 header
curl: request is missing authentication header - authentication header there
添加更多上下文:我正在尝试向 Seamless.gov API 发出 curl 请求。在不同的计算机上,相同的 curl 命令有效。但是,当我 运行 我的机器上的 curl 命令不起作用时。
curl -X GET -H "Content-Type: application/json" -H "Date: 1530285602" -H "Authorization: HMAC-SHA256 api_key=XXXXXXXX nonce=12335 signature=XXXXXXXXXXXXX" -d 'false' https://nycopp.seamlessdocs.com/api/form/CO1708XXXXXXXXXXXXX/elements
我有以下版本的curl
:
curl: stable 7.60.0 (bottled), HEAD [keg-only] Get a file from an HTTP, HTTPS or FTP server https://curl.haxx.se/ /usr/local/Cellar/curl/7.60.0 (423 files, 3MB) Poured from bottle on 2018-06-29 at 11:44:32 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/curl.rb
==> Dependencies Build: pkg-config ✔ Optional: openssl ✘, rtmpdump ✘, libssh2 ✘, c-ares ✘, libmetalink ✘, nghttp2 ✘
==> Options
--with-c-ares Build with C-Ares async DNS support
--with-gssapi Build with GSSAPI/Kerberos authentication support.
--with-libmetalink Build with libmetalink support.
--with-libssh2 Build with scp and sftp support
--with-nghttp2 Build with HTTP/2 support (requires OpenSSL)
--with-openssl Build with OpenSSL instead of Secure Transport
--with-rtmpdump Build with RTMP support
--HEAD Install HEAD version
==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.
If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/curl/lib
CPPFLAGS: -I/usr/local/opt/curl/include For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig
同样的curl
命令在另一台机器上可以运行,但在我的机器上不行,可能是版本或操作系统的问题。我正在 运行宁 Mac OS High Sierra
{
"error": true,
"error_log": [
{
"error_code": "missing_header",
"error_message": "Request is missing header: `Authorization`",
"error_description": "{\"Host\":\"XXXX.seamlessdocs.com\",\"Connection\":\"close\",\"X-Real-IP\":\"161.185.7.10\",\"X-Forwarded-For\":\"161.185.7.10\",\"X-Forwarded-Host\":\"nycopp.seamlessdocs.com\",\"X-Forwarded-Port\":\"443\",\"X-Forwarded-Proto\":\"https\",\"X-Original-URI\":\"\\/api\\/form\\/CO1XXXXXXXXXXXXXXX\\/elements\",\"X-Scheme\":\"https\",\"Content-Length\":\"5\",\"user-agent\":\"curl\\/7.54.0\",\"accept\":\"*\\/*\",\"content-type\":\"application\\/json\",\"date\":\"1530285602\",\"authorization\":\"HMAC-SHA256 api_key=XXXXXXXXXXXXXXX nonce=12335 signature=XXXXXXXXXXXXXX\"}"
},
{
报错信息中有一处提示:
==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.
OS X 已经安装了 curl 并使用了这个二进制文件。此版本不适用于您的要求。要找出 homebrew 在哪里安装了 curl 执行:
ll /usr/local/opt/curl
你会得到这样的输出:
lrwxr-xr-x 1 maltebuchmann admin 21B Jun 30 09:50 /usr/local/opt/curl -> ../Cellar/curl/7.60.0
根据该信息,您可以执行上述命令:
/usr/local/Cellar/curl/7.60.0/bin/curl -X GET -H "Content-Type: application/json" -H "Date: 1530285602" -H "Authorization: HMAC-SHA256 api_key=XXXXXXXX nonce=12335 signature=XXXXXXXXXXXXX" -d 'false' https://nycopp.seamlessdocs.com/api/form/CO1708XXXXXXXXXXXXX/elements
您可以按照打印的说明将安装文件夹添加到您的路径:
If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile
或者,你可以用自制软件强行link它:
brew link curl --force
但这样做需要您自担风险:)
添加更多上下文:我正在尝试向 Seamless.gov API 发出 curl 请求。在不同的计算机上,相同的 curl 命令有效。但是,当我 运行 我的机器上的 curl 命令不起作用时。
curl -X GET -H "Content-Type: application/json" -H "Date: 1530285602" -H "Authorization: HMAC-SHA256 api_key=XXXXXXXX nonce=12335 signature=XXXXXXXXXXXXX" -d 'false' https://nycopp.seamlessdocs.com/api/form/CO1708XXXXXXXXXXXXX/elements
我有以下版本的curl
:
curl: stable 7.60.0 (bottled), HEAD [keg-only] Get a file from an HTTP, HTTPS or FTP server https://curl.haxx.se/ /usr/local/Cellar/curl/7.60.0 (423 files, 3MB) Poured from bottle on 2018-06-29 at 11:44:32 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/curl.rb
==> Dependencies Build: pkg-config ✔ Optional: openssl ✘, rtmpdump ✘, libssh2 ✘, c-ares ✘, libmetalink ✘, nghttp2 ✘
==> Options
--with-c-ares Build with C-Ares async DNS support
--with-gssapi Build with GSSAPI/Kerberos authentication support.
--with-libmetalink Build with libmetalink support.
--with-libssh2 Build with scp and sftp support
--with-nghttp2 Build with HTTP/2 support (requires OpenSSL)
--with-openssl Build with OpenSSL instead of Secure Transport
--with-rtmpdump Build with RTMP support
--HEAD Install HEAD version
==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.
If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/curl/lib
CPPFLAGS: -I/usr/local/opt/curl/include For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig
同样的curl
命令在另一台机器上可以运行,但在我的机器上不行,可能是版本或操作系统的问题。我正在 运行宁 Mac OS High Sierra
{
"error": true,
"error_log": [
{
"error_code": "missing_header",
"error_message": "Request is missing header: `Authorization`",
"error_description": "{\"Host\":\"XXXX.seamlessdocs.com\",\"Connection\":\"close\",\"X-Real-IP\":\"161.185.7.10\",\"X-Forwarded-For\":\"161.185.7.10\",\"X-Forwarded-Host\":\"nycopp.seamlessdocs.com\",\"X-Forwarded-Port\":\"443\",\"X-Forwarded-Proto\":\"https\",\"X-Original-URI\":\"\\/api\\/form\\/CO1XXXXXXXXXXXXXXX\\/elements\",\"X-Scheme\":\"https\",\"Content-Length\":\"5\",\"user-agent\":\"curl\\/7.54.0\",\"accept\":\"*\\/*\",\"content-type\":\"application\\/json\",\"date\":\"1530285602\",\"authorization\":\"HMAC-SHA256 api_key=XXXXXXXXXXXXXXX nonce=12335 signature=XXXXXXXXXXXXXX\"}"
},
{
报错信息中有一处提示:
==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.
OS X 已经安装了 curl 并使用了这个二进制文件。此版本不适用于您的要求。要找出 homebrew 在哪里安装了 curl 执行:
ll /usr/local/opt/curl
你会得到这样的输出:
lrwxr-xr-x 1 maltebuchmann admin 21B Jun 30 09:50 /usr/local/opt/curl -> ../Cellar/curl/7.60.0
根据该信息,您可以执行上述命令:
/usr/local/Cellar/curl/7.60.0/bin/curl -X GET -H "Content-Type: application/json" -H "Date: 1530285602" -H "Authorization: HMAC-SHA256 api_key=XXXXXXXX nonce=12335 signature=XXXXXXXXXXXXX" -d 'false' https://nycopp.seamlessdocs.com/api/form/CO1708XXXXXXXXXXXXX/elements
您可以按照打印的说明将安装文件夹添加到您的路径:
If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile
或者,你可以用自制软件强行link它:
brew link curl --force
但这样做需要您自担风险:)