Skip to content

Instantly share code, notes, and snippets.

@EinPinsel
Created December 4, 2016 14:51
Show Gist options
  • Save EinPinsel/8c1ec4058031e2340a308631a9aa6815 to your computer and use it in GitHub Desktop.
Save EinPinsel/8c1ec4058031e2340a308631a9aa6815 to your computer and use it in GitHub Desktop.
function Netatmo-DoAuth {
$postParams = @{
grant_type='password';
client_id=$client_id;
client_secret=$client_secret;
username=$Netatmo_username;
password=$Netatmo_password
}
$Request = Invoke-WebRequest -Uri https://api.netatmo.com/oauth2/token -Method POST -Body $postParams -UseBasicParsing
if ($Request.StatusCode -eq 200) {
$ResponseJson = $Request.Content | ConvertFrom-Json
$global:access_token = $ResponseJson.access_token
$global:refresh_token = $ResponseJson.refresh_token
}
ELSE
{
write-error -message $Request.StatusDescription -ErrorId $Request.StatusCode
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment