[SOLVED] Token retrieval suddenly fails with an unreferenced error

The Netatmo API is a set of webservices allowing developers and third parties to access Netatmo device's data.
Post Reply
WpQ
Posts: 2
Joined: 14 Jul 2021, 17:15

[SOLVED] Token retrieval suddenly fails with an unreferenced error

Post by WpQ »

I use for quite a long time the API and I am now having problems to retrieve the token. The error is

Code: Select all

{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}
It is not referenced in the documentation (https://dev.netatmo.com/apidocumentation/oauth#errors).

The code I use is below and have not changed. I also tried to directly issue the POST call (via hoppscotch.io) and I get the same error message

Code: Select all

            r = requests.post(
                url='https://api.netatmo.net/oauth2/token',
                data={
                    'grant_type': 'password',
                    'client_id':REDACTED,
                    'client_secret':REDACTED,
                    'username': REDACTED,
                    'password': REDACTED,
                    'scope': 'read_station',
                },
                timeout=10
            )
            r.raise_for_status()
            access_token = r.json()['access_token']
The values for the fields are correct, I double-checked (and, again, they did not change).

Would you have any idea where to go from there?
Last edited by WpQ on 14 Jul 2021, 19:01, edited 1 time in total.
WpQ
Posts: 2
Joined: 14 Jul 2021, 17:15

Re: Token retrieval suddenly fails with an unreferenced error

Post by WpQ »

I found the issue: I was not setting the content type correctly (should be application/x-www-form-urlencoded)
Post Reply

Return to “Netatmo API”