【问题标题】:How can I change my cURL call to recognise more than 1 parameter?如何更改我的 cURL 调用以识别多个参数?
【发布时间】:2017-06-09 17:44:12
【问题描述】:

我想进行以下 curl 调用以获取访问令牌:

curl -k -XPOST --user "{user}" {url}/access_token -d 'grant_type=authorization_code&code={code}&redirect_uri={uri}' 

但是,我收到以下错误声明:

'code' is not recognized as ane internal or external command, operable program or batch file.
'redirect_uri' is not recognized as ane internal or external command, operable program or batch file.

当我检查跟踪时,我看到正文只包含这个:'grant_type=authorization_code

如何确保所有参数都通过?

【问题讨论】:

    标签: rest curl oauth call


    【解决方案1】:
    curl -X "POST" "{url}/access_token" \
     --user "{user}" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "code={code}" \
     --data-urlencode "redirect_uri={uri}" \
     --data-urlencode "grant_type=authorization_code"
    

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      似乎 & 字符被解释为“作为后台作业执行”。尝试使用反斜杠转义每个 & 字符 - 例如 \&

      或者,您可以将内容写入文件并通过参数 -d @file 引用该文件 @-字符对于 curl 知道文件是文件名很重要。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-10
        • 2021-08-26
        • 2017-04-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多