'--user' 对 curl 是什么意思 [英] What does '--user' mean with curl

查看:46
本文介绍了'--user' 对 curl 是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 API,我必须发送 POST 请求.我知道如何设置标题 (-H) 和 (-d) 是正文,但什么是--user".

I'm working with an API and I have to send a POST request. I know how to set a header (-H) and (-d) is the body, but what is "--user".

如果我通过 Postman 提交,或者在带有 axios 的文本编辑器中提交,或者只是普通的 XMLRequest,我应该在哪里添加?

If I submit this with Postman, or in a text editor with axios or just regular XMLRequest, where do I add this?

文档说它用于常规 http 身份验证.

The docs say it is for regular http auth.

curl -X POST -H "Content-Type: application/json" 
     --user "<client_id>:<client_secret>" 
     -d '{"grant_type": "client_credentials", "scope": "public"}' 
     ...

推荐答案

--user curl 中用于服务器认证的参数.因此,如果您不通过其他参数(如 --digest 或 --negotiate)定义身份验证类型,则表示用于 http 基本身份验证的 USER 参数,它也可以与 :PASSWORD 块组合以设置密码.您的问题的完整答案取决于您向其发送请求的 API 背后使用的身份验证类型,并且 curl 可能还不够,因为它支持一组有限的身份验证方案......

--user parameter in curl used for server authentication. So if you don't define authentication type via other parameters like --digest or --negotiate, it means USER parameter for http basic authentication, it also could be combined with :PASSWORD chunk to set a password as well. The full answer on your question depends on what kind authentication is used behind API you are sending request to, and maybe curl would not be enough for it, as it support a limited set of authentication schemes ...

这篇关于'--user' 对 curl 是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆