在调用 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/