Invalid access_token

The Netatmo API is a set of webservices allowing developers and third parties to access Netatmo device's data.
Post Reply
DarioPalmisano
Posts: 11
Joined: 02 Apr 2022, 16:50

Invalid access_token

Post by DarioPalmisano »

Hello,

I have some problem refreshing the access_token when it is expired.
In my script I use "Client credentials grant type", I can get the access_token and the refresh_token and for 3 hours I can get the temperature readings, then the access token expires and I try to refresh it (If I refresh it before it expires, it seems does not work), but following reads return:
{"error":{"code":2,"message":"Invalid access_token"}}

What is the correct way to proceed for refreshing?

Thanks in advance

Kind regards

Dario
DarioPalmisano
Posts: 11
Joined: 02 Apr 2022, 16:50

Re: Invalid access_token

Post by DarioPalmisano »

Hello,

to provide a little more detail:
after the initial three hours (corresponding to the default 10800 seconds) the following call:

headers = {
'Authorization': 'Bearer ' + access_token,
}
response = requests.request(\
'GET', \
netatmo_api_url + '/homestatus?home_id=' + home_id, \
data = '', \
headers = headers, \
)

returned
{"status":"ok","time_server":1655542717,"body":{"home":{"id":"RemovedForPrivacy"},"errors":[{"code":6,"id":"RemovedForPrivacy"}]}}
Any suggestion will be very welcome and appreciated
Thanks in advance
Dario
Leslie
Posts: 112
Joined: 12 Feb 2020, 11:07

Re: Invalid access_token

Post by Leslie »

Hello Dario,

I saw your message via the contact form, I answered you there

Have a good day,
Leslie - Community Manager
DarioPalmisano
Posts: 11
Joined: 02 Apr 2022, 16:50

Re: Invalid access_token

Post by DarioPalmisano »

Hi Leslie,
after a deep verification I have to admit that you were right and I was wrong!
Because of an error of logic the newly refreshed access_token was not used (as I thought), so causing the error.
Thanks for your kind support!
Best regards
Dario
Post Reply

Return to “Netatmo API”