【发布时间】:2018-08-30 18:23:34
【问题描述】:
我有原始的 curl 调用,据说它在 Unix 环境中工作(或他们在提供商办公室使用的任何东西)。
curl
-u ybeepbeepbeepa:eboopboopboopa
-k
-d "grant_type=mobile&customerId=SE.B2C/abcd&pin=1234&scope=openid"
-H "Content-Type:application/x-www-form-urlencoded"
https://xxx/oauth2/token
使用docs for curl,我将标志和属性交换为以下内容。
Invoke-WebRequest
-User ybeepbeepbeepa:eboopboopboopa
-Method POST
-Headers @{"Content-Type"="application/x-www-form-urlencoded"}
-Uri "https://xxx/oauth2/token?grant_type=mobile&customerId=SE.B2C/abcd&pin=1234&scope=openid"
我唯一没有翻译的部分是-k,它应该相当于--insecure。检查了上述文档,我找到了一些可能的替代方案,虽然有些牵强(例如 -AllowUnencryptedAuthentication),但它们都失败了,我没有想法。
- PowerShell 的 Invoke-WebRequest 中 curl 的 --insecure(或 -k)的等价物(它意外地被赋值为 curl,因为标志不同,所以像鸭子一样令人困惑)?
- 命令的其余部分是否正确移植到 PowerShell? (我已经将一些标志与 URL 一起作为 querty 字符串打包。而且我并不完全确定 Headers 的语法。)
【问题讨论】:
-
当您拥有自签名证书并且您使用的是 5.x 或更早版本的 powershell 时,上一篇文章应该可以帮助您使用 -k:stackoverflow.com/questions/11696944/…
标签: powershell curl