Created
December 4, 2016 14:51
-
-
Save EinPinsel/8c1ec4058031e2340a308631a9aa6815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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