invoke - Powershell Invoke-RestMethod 授权 header

标签 invoke powershell-4.0

在调用 Invoke-RestMethod 时使用 Powershell,例如:

Invoke-RestMethod -Method Get -Uri "https://google.com/api/GetData" -Headers $headers

$headers存在
$headers = @{
    Authorization="Secret $username $password"
    Content='application/json'
}

参数 $username 的预期格式是什么?和 $password ?

最佳答案

据我所知,您必须在请求 header 中发送 OAuth2 token 。

$headers = @{
    Authorization="Bearer $token"
}

也许下面的博客文章让你知道如何做到这一点。
https://lazyadmin.nl/it/connect-to-google-api-with-powershell/

关于invoke - Powershell Invoke-RestMethod 授权 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54191266/

相关文章:

powershell - 在PowerShell脚本中返回解析函数

powershell - 重命名文件共享中的文件夹

powershell - Powershell脚本无法发送电子邮件警报

invoke - C# - Emgu cv 如何使用 CvInvoke.cvLoadImage ("ClassPic1.jpg") 作为 intptr 从文件夹加载图像并访问它

c# - 在调用新操作时帮助理解 C# 语法

c# - 参数计数与 Invoke 不匹配?

.net - 获取与 IP 关联的所有 DNS 记录

xml - PowerShell XML SelectNodes 无法处理 XPath

c# - 调用任何跨线程代码的最佳方式?

java - jOOQ - 方法调用