Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell Invoke-RestMethod Authorization Header

While invoking an Invoke-RestMethod using Powershell like:

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

and $headers being

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

What is the format expected for the parameters $username and $password?

like image 463
Reddipalle Nagarjun Avatar asked Jan 15 '19 00:01

Reddipalle Nagarjun


1 Answers

As far as I know you have to send a OAuth2 token in the request headers.

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

Perhaps the following blog post gives you an idea how to do so. https://lazyadmin.nl/it/connect-to-google-api-with-powershell/

like image 147
rufer7 Avatar answered Sep 22 '22 15:09

rufer7