我正在使用curl查询
curl http://username:password@ip:8091/pools/default/buckets/price/docs/06d4c5d8-71d3-4216-89ac-9da44f9b5c54
Ans工作正常,并返回文档。
但是现在我需要在scala代码中使用http get
val req = Http(createURI(uri, path))
.headers(headers)
.method(method)
.body(body)
.timeout(connTimeoutMs = CONNECT_TIMEOUT, readTimeoutMs = READ_TIMEOUT)
.option(HttpOptions.allowUnsafeSSL)
现在的uri是相同的
uri = URI.create("http://username:password@ip:8091/pools/default/buckets/price/docs/06d4c5d8-71d3-4216-89ac-9da44f9b5c54")
但是当我运行它时,我收到401 Unauthorized.
知道如何传递用户名和密码吗?
您可以使用-u参数
curl -u <userid>:<userpassword> http://ip:8091/pools/default/buckets/price/docs/06d4c5d8-71d3-4216-89ac-9da44f9b5c54
裁判:https://curl.haxx.se/docs/manual.html