Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"message": "Invalid access token", #4

Open
jawilczek opened this issue May 10, 2022 · 55 comments
Open

"message": "Invalid access token", #4

jawilczek opened this issue May 10, 2022 · 55 comments

Comments

@jawilczek
Copy link

Hi

i got error message "message": "Invalid access token" from 9 May 16:00 CET

before, the script worked without any problems, the user and password were checked via "https://my.netatmo.com/app/station" I can log in without any problems.

I have not made any changes to the system, do you have similar problems?

--
Jacek

@Dani1802
Copy link

Same here, I am using this script for a long time without any problems. But since yesterday (09.05.2022) afternoon I'm getting "Invalid access token".
My Credentials are working and the weather station is working, too.
Weather Data is available in the iOS App and at https://my.netatmo.com/app/station

@technarf
Copy link

I think it is a Netatmo side change in the auth process (I have the same issue since two days), but I don't know what to change in the code to make it work again...

@tjluoma
Copy link

tjluoma commented May 11, 2022

I use a Mac menu bar app that also logged me out suddenly so I'm guessing Netatmo changed something that broke other tools.

@Dani1802
Copy link

Not sure if this helps.. I'm using Hoobs with this plugin: https://plugins.hoobs.org/plugin/homebridge-eveatmo
My Netatmo values are still shown in the Apple Home App and I just checked, they match with the values in the Netatmo App.

@petrbrouzda
Copy link

Same problem here.

@Dani1802
Copy link

Dani1802 commented May 13, 2022

I think I've got a fix for this.
The Access Token needs to be fetched in another way using the client id and client secret from your app on https://dev.netatmo.com/

For me it is working, but I've changed your script to my needs.
Maybe someone else could test and confirm?

Regards,
Dani

    # ------------------------------------------------------
    # Now let's fetch the data
    # ------------------------------------------------------

    # get token from hidden <input> field
#    TOKEN="$(curl --silent -c $SESSION_COOKIE $URL_LOGIN | sed -n '/token/s/.*name="_token"\s\+value="\([^"]\+\).*/\1/p')"

    # and now we can login using cookie, id, user and password
#    curl --silent -d "_token=$TOKEN&email=$USER&password=$PASS" -b $SESSION_COOKIE -c $SESSION_COOKIE $URL_POSTLOGIN > /dev/null

    # next we extract the access_token from the session cookie
    ACCESS_TOKEN=`curl --silent  --location --request POST "https://api.netatmo.com/oauth2/token" \
                        --form "grant_type=password" \
                        --form "client_id=YOUR_CLIENT_ID" \
                        --form "client_secret=YOUR_CLIENT_SECRET" \
                        --form "username=YOUR_USERNAME" \
                        --form "password=YOUR_PASSWORD" | jq -r '."access_token"'`

    # build the POST data
    PARAM="access_token=$ACCESS_TOKEN"

    # now download json data
    curl -d $PARAM $API_GETMEASURECSV

    # clean up
#    rm $SESSION_COOKIE

@jawilczek
Copy link
Author

I only had to change the json parser parameter and then section works fine

jq -r '.access_token'

@debianatoe
Copy link

Thank you for your change proposals. Unfortunately it does not work for me. Do you have any idea what to do without using jq command? What does "YOUR_CLIENT_SECRET" mean?

@jawilczek
Copy link
Author

What does "YOUR_CLIENT_SECRET" mean?
@debianatoe please read again post @Dani1802 especially:

"I think I've got a fix for this.
The Access Token needs to be fetched in another way using the client id and client secret from your app on https://dev.netatmo.com/"

p.s.

--
Jacek

@debianatoe
Copy link

Yes, I understand. So the old access method used by netatmo.sh is disabled since 9th of May 2022. The new access method described in https://dev.netatmo.com/ is more complex. You first have to create your own "Netatmo-App" and then you got the client id and the client secret. So perhaps we have more security but also a lot of work.

@Gerudom
Copy link

Gerudom commented May 23, 2022

Does anyone have a solution or idea ?

I filled out the form from above from Dani1802 with my credentials missing like secret and id but no effect.

Also changed the line from jawilczek without the "

{"error":{"code":10,"message":"'device_id' is mandatory"}}

is now the error if I go with the codes above

Damn Netatmo every year the same shit with the changed authentication

@jawilczek
Copy link
Author

which procedure did you edit ?
im ask because this patch only corrects "getmeasure ()" procedure (netatmo.sh -D)

@jawilczek
Copy link
Author

jawilczek commented May 24, 2022

"my" version below based on @Dani1802 fix. (.csv is no longer supported - only .json)

netatmo.txt

@debianatoe
Copy link

@jawilczek Thank you for your new version. It works for me partly. min_file_size has to be adjusted, because the json files are obviously smaller than the csv files, e.g. I had to set min_file_size=6000 for the -y option to get results.
I agree with @Gerudom that these self-important changes on Netatmo's part are frustrating. Why do we no longer have a csv format but only json? That means a lot of customization work.

@jawilczek
Copy link
Author

@debianatoe
Thanks for the information, I download data only in -D mode.
When I did json download tests (witout parameters), my first measurements were ok (but I never waited for all devices), today I tested and you are right the parameter needs to be reduced.

p.s.
ipersonally, I prefer the json format - but you are right it is a pity that the changes did not allow the previous formats too

@Gerudom
Copy link

Gerudom commented May 26, 2022

Jawilczek where can I find the information that csv export is no longer available ? I export all data via csv and import that in my own database to make comparisons between weather data since years now. Hopefully not true

@jawilczek
Copy link
Author

jawilczek commented May 26, 2022

@Gerudom
here is a description of the current api - you may notice that there is no data format selection

https://dev.netatmo.com/apidocumentation/weather#getmeasure

--
Jacek

@Gerudom
Copy link

Gerudom commented May 26, 2022

This is a horrible. Feels like the end of everything I collect data since year 2016
I need to convert data now from Json to CSV Format that I can import the data back into the database. Jesus...

Unfortunately the export files you export are named like

7617KGW
0U3IYR
D

I found out which one represents which module. So far so good. Where is the code line for that names ?

But in that export which value is what ? This is my outdoor module e.g export JSON from your file

beg_time | step_time | value/0/0 | value/0/1 | value/1/0 | value/1/1 | value/2/0 | value/2/1

Value 1/1 could be Temperature but the rest ?

Isn't it possible to name the export values like the values it represents like

"module_name": "Außen",
"firmware": 50,
"last_message": 1653564028,
"last_seen": 1653563984,
"rf_status": 83,
"battery_vp": 5610,
"dashboard_data": {
"time_utc": 1653563984,
"Temperature": 20.9,
"Humidity": 48,
"min_temp": 12.2,
"max_temp": 20.9,
"date_max_temp": 1653563368,
"date_min_temp": 1653535587,
"temp_trend": "up"

Thanks

@jawilczek
Copy link
Author

jawilczek commented May 26, 2022

I use -D option & jq json parser

eg.

netatmo.sh -D | jq ".body.modules[1].dashboard_data.WindStrength"
i get Wind strength

netatmo.sh -D | jq ".body.modules[3].dashboard_data.CO2"
i get co2 value

of course you can get all the data into a file and offline it is parsed with jq

--
Jacek

@Gerudom
Copy link

Gerudom commented May 26, 2022

I don't get that to work like that and how I need it.
Too much Linux and data conversions between. Damn

@Dani1802
Copy link

@Gerudom why converting from JSON to CSV and then import?
I wrote a script, that fetches the latest data from Netatmo and writes them directly into a Influx Database.

If you or anyone else is interested in that, I've published it here: https://github.com/Dani1802/netatmo_to_influx

@Gerudom
Copy link

Gerudom commented May 28, 2022

@Dani1802 why converting from JSON to CSV and then import? -> Until now it was CSV Exports since 2016. I have a MySQL DB. Need to look how this is possible. There is a lot of data already stored in that Database since that years...

I put everything in and I get data out of your example. Now I just need to import that data into my MYSQL Database anyhow... curl is a HTTP client. MySQL doesn't use the HTTP protocol.

@Dani1802
Copy link

@Gerudom maybe you can use something like:

mysql --user=$DB_USER --password=$DB_PASSWD $DB_NAME << EOF
INSERT INTO $TABLE (id, day, time, rank) VALUES (NULL, "$day", "$time", "$rank");
EOF

To insert the data to the database within the bash script

@Gerudom
Copy link

Gerudom commented May 28, 2022

Ok got it thanks @Dani1802. I once got a field exported called dt_readings if I do so manually from Netatmo Page it's called "timezone" in which a readable date was in beside the ms unix timestamp. Do you know if this datafield is still exportable ?

@debianatoe
Copy link

There are some JSON to CSV converters:

I don't know which one is really suitable.

@debianatoe
Copy link

@Dani1802 Thanks for your script writing Netatmo data into a Influx database. The problem is that everyone use another database. You use Influx, @Gerudom uses MySQL and I use PostgreSQL. So CSV should be a common database independent format. I cannot understand why Netatmo dropped it.

@debianatoe
Copy link

Can anyone help me interpret the JSON data? With the CSV data, we had a header line and then a single line for each measurement time, e.g.

Timestamp; "Timezone : Europe/Berlin";Temperature
1651972187;"2022/05/08 03:09:47";14.3

In JSON format it looks like this for me:

    {
      "beg_time": 1653429818,
      "step_time": 307,
      }, "value": [
        [
          15.2
        ],
        [
          15.1
        ],
        [
          15
        ]
      ]
    },

beg_time is timestamp. But what does step_time mean? And why do I have 3 (different) values?

@Dani1802
Copy link

@debianatoe Yes, you are right with different databases, but I think every DB should have a CLI to write data. So for me, the main difficulty was to get the data from Netatmo and to parse them for the information I need.
I had a look at my JSON, and can find step_time in there.

In my JSON a indoor module for example looks like this:

  {
    "_id": "1234567890",
    "type": "NAModule4",
    "module_name": "Schlafzimmer",
    "last_setup": 1546793619,
    "data_type": [
      "Temperature",
      "CO2",
      "Humidity"
    ],
    "battery_percent": 59,
    "reachable": true,
    "firmware": 51,
    "last_message": 1653845880,
    "last_seen": 1653845861,
    "rf_status": 84,
    "battery_vp": 5262,
    "dashboard_data": {
      "time_utc": 1653845861,
      "Temperature": 21.3,
      "CO2": 505,
      "Humidity": 43,
      "min_temp": 20.7,
      "max_temp": 21.6,
      "date_max_temp": 1653792900,
      "date_min_temp": 1653777211,
      "temp_trend": "stable"
    }
  }

and the rain module looks like this:

  {
    "_id": "0987654321",
    "type": "NAModule3",
    "module_name": "Regen",
    "last_setup": 1560975450,
    "data_type": [
      "Rain"
    ],
    "battery_percent": 59,
    "reachable": true,
    "firmware": 12,
    "last_message": 1653845880,
    "last_seen": 1653845874,
    "rf_status": 62,
    "battery_vp": 5096,
    "dashboard_data": {
      "time_utc": 1653845874,
      "Rain": 0,
      "sum_rain_1": 0,
      "sum_rain_24": 4.2
    }
  }

@debianatoe
Copy link

It seems easier to me to get data from a financial institution than from Netatmo. Since all my pre-checks are based on csv, I decided to convert JSON to CSV.
The data you posted are from the -D option. I need the option -y and so I get another JSON format structure. I found that the structure becomes simpler if you use the optimize=false parameter.

@S474N
Copy link

S474N commented Nov 17, 2022

Hi guys, is possible to download thermostat data?

@S474N
Copy link

S474N commented Apr 2, 2023

How long a range does it take for you? I tried the command:
./netatmo.sh -s '2023-03-02' -e '2023-04-01'

and unfortunately it takes a maximum of 3 days to download.

@topsurfer
Copy link

Was there a change again ?
Till two days before the version from jawilczek was working fine (I use the -D parameter), but now I also get:
"Invalid access token"

At https://dev.netatmo.com/apps I reset my client ID and client secret and fill the new data in the script, but the same message.

I see also the fields "Token generator: Choose scopes =>" and than => "Read station", have I to use this also (now) ?
Than I get "Access token" and "Referesh token", have I to use this also? Where or how?

@S474N
Copy link

S474N commented Jul 15, 2023

@topsurfer : #5

@jawilczek
Copy link
Author

Hi

two days ago, netatmo will turn off the old authorization method - which it warned about.
i made small changes following [https://github.com/philippelt/netatmo-api-python] in the code and it's ok

**"BREAKING CHANGE: Netatmo seems no longer (july 2023) to allow grant_type "password", even for an app credentials that belong to the same account than the home. They have added the capability of creating access_token/refresh_token couple from the dev page (the location where app are created). As a consequence, the username/password credentials can no longer be used and you must replace them with a new parameter REFRESH_TOKEN that you will get from the web interface. "**__

Below is the concept - not the complete code

------------------------------------------------------

Parsing Arguments

------------------------------------------------------

ID=$1
SEC=$2
TOKEN=$3
ACCESS_TOKEN=curl --silent --location --request POST "https://api.netatmo.com/oauth2/token" \ --form "grant_type=refresh_token" \ --form "client_id=$ID" \ --form "client_secret=$SEC" \ --form "refresh_token=$TOKEN" | jq -r '.access_token'

device list requested

if [ "${list_devices}" == "1" ] ; then
if hash jq >/dev/null 2>&1 ; then
listDevices "${id}" "${sec}" "${refresh}" | jq '.'
else
listDevices "${id}" "${sec}" "${refresh}"
fi
exit 0
fi

@S474N
Copy link

S474N commented Jul 15, 2023

@jawilczek would it be possible for you to fork the whole project and make changes there?

@jawilczek
Copy link
Author

netatmo.txt

Working code is attached

of course you have to fill in your configuration data and get the refreshcode from the netamto website

--
Jacek

@S474N
Copy link

S474N commented Jul 15, 2023

Script works, but there is problem with downloading. For example command:
./netatmo.sh -s '2023-01-02' -e '2023-02-01'

This command will download only from 2.jan to 5.jan and not to 1.feb.

Could you please check it yourself?

@jawilczek
Copy link
Author

jawilczek commented Jul 16, 2023

I personally only use the -D option, but I checked with your parameters, the result is the same as yours.

From what I've read, it's a netatmo API limitation.

Plese read https://dev.netatmo.com/apidocumentation/weather#getmeasure

parameter limit Maximum number of measurements (default and max are 1024)

--
Jacek

@S474N
Copy link

S474N commented Jul 16, 2023

Uff, need all last and actuall year :D :D

@jawilczek
Copy link
Author

you can download day by day in some loop :)

--
Jacek

@S474N
Copy link

S474N commented Jul 17, 2023

So need script for this :D It would be a pain to do it manually.

@Gerudom
Copy link

Gerudom commented Jul 24, 2023

@Dani1802 He Dani 1 year later Netatmo did it again :(
I got the script running from jaqukczek but still again just JSON results...
You once coded something

@Gerudom why converting from JSON to CSV and then import?
I wrote a script, that fetches the latest data from Netatmo and writes them directly into a Influx Database.

If you or anyone else is interested in that, I've published it here: https://github.com/Dani1802/netatmo_to_influx

can you get that running again ? My whole solution was build from that again. I'm back at the point May 2022 1 year later...Damn Netatmo

@Dani1802
Copy link

@Dani1802 He Dani 1 year later Netatmo did it again :( I got the script running from jaqukczek but still again just JSON results... You once coded something

@Gerudom why converting from JSON to CSV and then import? I wrote a script, that fetches the latest data from Netatmo and writes them directly into a Influx Database.

If you or anyone else is interested in that, I've published it here: https://github.com/Dani1802/netatmo_to_influx

can you get that running again ? My whole solution was build from that again. I'm back at the point May 2022 1 year later...Damn Netatmo

You need to switch from Username/Password Authentication to Token Authentication and set the scope at http://dev.netatmo.com/

Afterwards this should work:

ACCESS_TOKEN=`curl  --location --request POST "https://api.netatmo.com/oauth2/token" \
           --form "grant_type=refresh_token" \
           --form "client_id=$CLIENT_ID" \
           --form "client_secret=$CLIENT_SECRET" \
           --form "refresh_token=$REFRESH_TOKEN" \
           | jq -r '."access_token"'`
curl -d "access_token=$ACCESS_TOKEN" https://api.netatmo.com/api/getstationsdata

@Gerudom
Copy link

Gerudom commented Jul 24, 2023

@Dani1802 Hello unfortunately not :(

Module=Hauptmodul
Database=indoor_data
jq: error (at :1): Cannot iterate over null (null)
temperature:
jq: error (at :1): Cannot iterate over null (null)
humidity:
jq: error (at :1): Cannot iterate over null (null)
co2:
jq: error (at :1): Cannot iterate over null (null)
pressure:
jq: error (at :1): Cannot iterate over null (null)
noise:
jq: error (at :1): Cannot iterate over null (null)

From where comes the refresh token ? the netatmo file where the login data is stored ?

@Dani1802
Copy link

@Dani1802 Hello unfortunately not :(

Module=Hauptmodul Database=indoor_data jq: error (at :1): Cannot iterate over null (null) temperature: jq: error (at :1): Cannot iterate over null (null) humidity: jq: error (at :1): Cannot iterate over null (null) co2: jq: error (at :1): Cannot iterate over null (null) pressure: jq: error (at :1): Cannot iterate over null (null) noise: jq: error (at :1): Cannot iterate over null (null)

From where comes the refresh token ? the netatmo file where the login data is stored ?

You need to generate the refresh token at http://dev.netatmo.com/.
Then you can store it in the file or in the script wherever you want.

@Gerudom
Copy link

Gerudom commented Jul 24, 2023

@Dani1802 I did but unfortunately didn't work
Something is with the code
It get's the names of the modules but not the data...

#!/bin/bash

API_URL="https://api.netatmo.com/api/getstationsdata"
AUTH_URL="https://api.netatmo.com/oauth2/token"


function getData {
ACCESS_TOKEN=`curl  --location --request POST "https://api.netatmo.com/oauth2/token" \
           --form "grant_type=refresh_token" \
           --form "client_id=$CLIENT_ID" \
           --form "client_secret=$CLIENT_SECRET" \
           --form "refresh_token=$REFRESH_TOKEN" \
           | jq -r '."access_token"'`
curl -d "access_token=$ACCESS_TOKEN" https://api.netatmo.com/api/getstationsdata
}



function Base {
        echo ---------------------
        echo Module=$1
        echo Database=$2
        temperature=`jq -r ".body.devices[] | select(.module_name==\"$1\") | .dashboard_data.Temperature" <<< $JSON`; echo temperature: $temperature
        humidity=`jq -r ".body.devices[] | select(.module_name==\"$1\") | .dashboard_data.Humidity" <<< $JSON`; echo humidity: $humidity
        co2=`jq -r ".body.devices[] | select(.module_name==\"$1\") | .dashboard_data.CO2" <<< $JSON`; echo co2: $co2
        pressure=`jq -r ".body.devices[] | select(.module_name==\"$1\") | .dashboard_data.Pressure" <<< $JSON`; echo pressure: $pressure
        noise=`jq -r ".body.devices[] | select(.module_name==\"$1\") | .dashboard_data.Noise" <<< $JSON`; echo noise: $noise
		time=`jq -r ".body.devices[] | select(.module_name==\"$1\") | .dashboard_data.time_utc" <<< $JSON`; echo time: $time
}

function Indoor1 
{
        echo ---------------------
        echo Module=$1
        echo Database=$2
        temperature=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.Temperature" <<< $MODULES`; echo temperature: $temperature
        humidity=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.Humidity" <<< $MODULES`; echo humidity: $humidity
        co2=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.CO2" <<< $MODULES`; echo co2: $co2
        battery_percent=`jq -r ". | select(.module_name==\"$1\") | .battery_percent" <<< $MODULES`; echo battery_percent: $battery_percent
		time=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.time_utc" <<< $MODULES`; echo time_utc: $time
		
	

      
}


function Indoor2 
{
        echo ---------------------
        echo Module=$1
        echo Database=$2
        temperature=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.Temperature" <<< $MODULES`; echo temperature: $temperature
        humidity=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.Humidity" <<< $MODULES`; echo humidity: $humidity
        co2=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.CO2" <<< $MODULES`; echo co2: $co2
        battery_percent=`jq -r ". | select(.module_name==\"$1\") | .battery_percent" <<< $MODULES`; echo battery_percent: $battery_percent
		time=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.time_utc" <<< $MODULES`; echo time_utc: $time


		
      
}

function Outdoor {
        echo ---------------------
        echo Module=$1
        echo Database=$2
        temperature=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.Temperature" <<< $MODULES`; echo temperature: $temperature
        humidity=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.Humidity" <<< $MODULES`; echo humidity: $humidity
        battery_percent=`jq -r ". | select(.module_name==\"$1\") | .battery_percent" <<< $MODULES`; echo battery_percent: $battery_percent
		time=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.time_utc" <<< $MODULES`; echo time_utc: $time
     	   
		   

}

function Rain {
        echo ---------------------
        echo Module=$1
        echo Database=$2
        rain=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.Rain" <<< $MODULES`; echo rain: $rain
        sum_rain_1=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.sum_rain_1" <<< $MODULES`; echo sum_rain_1: $sum_rain_1
        sum_rain_24=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.sum_rain_24" <<< $MODULES`; echo sum_rain_24: $sum_rain_24
        battery_percent=`jq -r ". | select(.module_name==\"$1\") | .battery_percent" <<< $MODULES`; echo battery_percent: $battery_percent
		time=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.time_utc" <<< $MODULES`; echo time_utc: $time
      



}

function Wind {
        echo ---------------------
        echo Module=$1
        echo Database=$2
        windstrength=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.WindStrength" <<< $MODULES`; echo windstrength: $windstrength
        windangle=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.WindAngle" <<< $MODULES`; echo windangle: $windangle
        guststrength=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.GustStrength" <<< $MODULES`; echo guststrength: $guststrength
        angle=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.GustAngle" <<< $MODULES`; echo gustangle: $angle
        battery_percent=`jq -r ". | select(.module_name==\"$1\") | .battery_percent" <<< $MODULES`; echo battery_percent: $battery_percent
		time=`jq -r ". | select(.module_name==\"$1\") | .dashboard_data.time_utc" <<< $MODULES`; echo time_utc: $time
		
			

		
		
		
       
}

JSON=`getData`
MODULES=`echo $JSON | jq '.body.devices[].modules[]'`

@Dani1802
Copy link

Dani1802 commented Jul 24, 2023

@Gerudom

can you please try to execute (with you ID / Secret / Token)

curl  --location --request POST "https://api.netatmo.com/oauth2/token" \
  --form "grant_type=refresh_token" \
 --form "client_id=$CLIENT_ID" \
 --form "client_secret=$CLIENT_SECRET" \
 --form "refresh_token=$REFRESH_TOKEN"

Output should be some sting like

{"scope":["read_station"], "access_token":"58******************************************0a", "refresh_token":"58*********************8a", "expires_in":10800,"expire_in":10800}

@Dani1802
Copy link

@Gerudom
using the script you posted above and executing "Base Wohnzimmer" afterwards I get the values from my Main Station

~$ Base Wohnzimmer
---------------------
Module=Wohnzimmer
Database=
temperature: 23.8
humidity: 60
co2: 519
pressure: 1022.5
noise: 36
time: 1690229036

I think there's something wrong with your refresh token or token scope

@Gerudom
Copy link

Gerudom commented Jul 25, 2023

@Dani1802
Ich hab die Variablen raus und hab das direkt eingegeben ohne 2. Datei. Nun funktioniert es wieder.
Vielen Dank Dir

@Gerudom
Copy link

Gerudom commented Jun 19, 2024

@Dani1802 ich könnte kotzen mit der Firma Netatmo...
Am 3.6. ist wieder was verändert worden...

Code ist immer noch derselbe bei mir was stimmt nicht oder was fehlt. Bzw. ist es mittlerweile so, dass jeder Export tatsächlich einen neuen Token braucht ? Den generiere ich manuell gerade via diesem dev.netatmo button... das kann ein Script ja nicht wirklich

Kannst du mir hier evlt. nochmal helfen ? Danke

Meine Funktion aktuell

function getData {
ACCESS_TOKEN=`curl  --location --request POST "https://api.netatmo.com/oauth2/token" \
           --form "grant_type=refresh_token" \
           --form "client_id=ID" \
           --form "client_secret=SECRET" \
           --form "refresh_token=TOKEN" \
           | jq -r '."access_token"'`
curl -d "access_token=$ACCESS_TOKEN" https://api.netatmo.com/api/getstationsdata
}

Auch der Fehler ist ein Altbekannter

jq: error (at <stdin>:1): Cannot iterate over null (null) temperature: jq: error (at <stdin>:1): Cannot iterate over null (null) humidity: jq: error (at <stdin>:1): Cannot iterate over null (null) co2: jq: error (at <stdin>:1): Cannot iterate over null (null) pressure: jq: error (at <stdin>:1): Cannot iterate over null (null) noise: jq: error (at <stdin>:1): Cannot iterate over null (null)

@jawilczek
Copy link
Author

@Gerudom ponieważ ty nie piszesz po angielsku to ja też pozwolę sobie odpisać w moim natywnym języku.
proponuje zmienić projekt na rozwijany i który działa [https://github.com/NicNull/netatmo-bash], korzystam z niego od kilku tygodni i mi się podoba.

@ALL
I recommend another netatmo bash project :) which is fresh and works [https://github.com/NicNull/netatmo-bash]

--
Jacek

@topsurfer
Copy link

topsurfer commented Jun 20, 2024

Since few days for me the script give "Invalid access token" back, before it works for 11 month (plus/minus) fine.

Has Netatmo changed something again or is the token (simply) expired?
But how can I refresh, I find this: https://dev.netatmo.com/apidocumentation/oauth#refreshing-a-token
But how should a curl (?) command looks like that the token is renewed and working again ?

Or should I create a new complete new "setting" with client-secret and refresh -token?

Thx!

@tob33
Copy link

tob33 commented Jun 20, 2024

Since few days for me the script give "Invalid access token" back, before it works for 11 month (plus/minus) fine.

Has Netatmo changed something again or is the token (simply) expired? But how can I refresh, I find this: https://dev.netatmo.com/apidocumentation/oauth#refreshing-a-token But how should a curl (?) command looks like that the token is renewed and working again ?

Or should I create a new complete new "setting" with client-secret and refresh -token?

Thx!

Looks like there is a new OATH method required after May 2024 API update as stated in the recommended project here: https://github.com/NicNull/netatmo-bash

@topsurfer
Copy link

topsurfer commented Jun 23, 2024

Danke für den Hinweis!

Beim eingeben der erzeugten URL und der darauffolgenden Fehlermeldung/Timeout muss man beachten, das der benötigte Code zur Eingabe in der Shell in der dann angezeigten URL im Browser steht.

Der Innensensor wird nun korrekt ausgelesen,
der Aussensenor wird zwar "gesehen", aber keine Messwerte angezeigt.
Der Regenmesser und Windsensor wird gar nicht erkannt (funktioniert aber alles, sowohl in der App als auch im Webfrontend).

Wo kann hier der Fehler liegen?

So schaut es bei mir aus:

`./netatmo-bash.sh
[INFO] Values stored in Mhome.csv

[Mhome] [2024-06-23 13:15:43]
-------------------------- Indoor ---------------------------------
Temperature: 23.2 °C | Humidity: 53 % | CO2: 413 ppm
-------------------------- Outdoor --------------------------------
Temperature: null °C | Humidity: null% | Pressure: 1019.2 mb
`

Die erzeugte csv-Datei sieht so aus:

cat Mhome.csv

Date,Indoor Temp,Indoor Humidity,Indoor CO2, Outdoor Temp,Outdoor Humidity, Pressure
2024-06-23T11:12:07Z,23.2,53,413,null,null,1019.2

@jawilczek
Copy link
Author

Use the -j filename switch
you will receive a full export to json, everything appears in it - anemometer and rain gauge too

e.g:

./netatmo-bash.sh -q -j data.json

--
Jacek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants