Refresh token - Error 400 Bad request

The Netatmo API is a set of webservices allowing developers and third parties to access Netatmo device's data.
Post Reply
aureliend2000
Posts: 4
Joined: 17 Apr 2018, 13:59

Refresh token - Error 400 Bad request

Post by aureliend2000 » 17 Apr 2018, 15:02

Hello,

I am new to JSON and I try to access to my Netatmo Welcome in order to force my "AtHome" status when I am connected to my home Wifi (using Tasker or Automagic or such Android software). That way the system will rely on face recognition and also use my phone to know that I am connected to the home Wifi and even if the camera does not see me for a longtime, it will still consider me as "at home" if I am connected to the homeWifi. Such functionnality does not exist in IFTTT for Netatmo.

So, I created an app on Netatmo website with a client id and a secret id. Then I managed to get an access token and a refresh token.

After doing so, I was able to use this request for example in a navigator in order to get back information from my cam (home id, list of persons, etc...).

https://api.netatmo.com/api/gethomedata ... ccesstoken

Using the "Setpersonshome" method, I was also able to tell my Welcome that I am at home even if I was not.
Perfect :D

But after 3 hours, the access token is not valid anymore, so I have this anwser :

Code: Select all

{
    "error": {
        "code": 3,
        "message": "Access token expired"
    }
}
No problem, I checked the documentation on Netatmo website and normally, using following request, I should be able to get a new access token without doing again the full authentication process.

https://api.netatmo.com/oauth2/token?gr ... mysecretid

But everytime I try, I have this anwser...

Code: Select all

{
    "error": "invalid_request"
}
So I searched if I can find some information about this on Internet... sadly nothing worked. So I surely misunderstood something but based on Netatmo documentation, I don't understand why it is not working.

Could someone be kind enough to explain a newbie what I am doing wrong ? ;)

Thanks a lot.

aureliend2000
Posts: 4
Joined: 17 Apr 2018, 13:59

Re: Refresh token - Error 400 Bad request

Post by aureliend2000 » 18 Apr 2018, 12:02

I solved partially my problem. By coding a small python script, it worked properly and I was able to refresh my token. So it seems only classic HTTP request with explicit params is not allowed even if it works fine for some methods.

Céline
Posts: 37
Joined: 20 Nov 2017, 18:17

Re: Refresh token - Error 400 Bad request

Post by Céline » 19 Apr 2018, 18:15

Hi,

You get an error because you're using a GET. You need to make a POST.

Regards,
Céline - Netatmo Team :D

Post Reply

Return to “Netatmo API”