Upgrade Netatmo Authentication
Closed this issue · 6 comments
Accordning to an email from Netatmo we need to adjust how the adapter works regarding the Authentication:
Authorization Code Grant Method is the new requirements
Ok, then we can start here with a short GitHub test before we release.
Before we start: You NEED TO use Admin 6.2.14 - all older versions will NOT work for the configuration! This was also "just now" released and will come to official Beta repo soon.
After having Admin 6.2.14 you can update the adapter from GitHub. The version did not change for now ... so please restart manually after update.
If you want to support best then stop the instance BEFORE the update, setthe instance loglevel to debug, install the new version and then start - so we can make sure to get debug logs of the first start after update too :-) I would be interested in seeing them once.
The config fields for username/password are removed in this version because a login using them will soon no longer work.
If you had entered them then there is a good chance that after the update they are just used for the initial authentication "the old way" to also get access and refresh tokens that from now on are only used.
Ideally the refresh tokens are used initially on each adapter start to get new tokens and this works "forever". In worst case a new Login is needed manually after a very long "not using the adapter" time.
For other cases just the the new "Authenticate with Netatmo" Button in the Admin UI to do an authentication as required now to get the initial keys.
To support in testing please check:
- log after initail run and other starts
- check that all stuff works (consider "doorbell" still as not finished, so do not check there)
- if you like: try out Authentications with and without individual keys and such :-)
My log:
2022-08-06 19:22:35.343 - debug: netatmo.0 (3501186) Redis Objects: Use Redis connection: 127.0.0.1:9001
2022-08-06 19:22:35.431 - debug: netatmo.0 (3501186) Objects client ready ... initialize now
2022-08-06 19:22:35.434 - debug: netatmo.0 (3501186) Objects create System PubSub Client
2022-08-06 19:22:35.436 - debug: netatmo.0 (3501186) Objects create User PubSub Client
2022-08-06 19:22:35.541 - debug: netatmo.0 (3501186) Objects client initialize lua scripts
2022-08-06 19:22:35.556 - debug: netatmo.0 (3501186) Objects connected to redis: 127.0.0.1:9001
2022-08-06 19:22:35.612 - debug: netatmo.0 (3501186) Redis States: Use Redis connection: 127.0.0.1:9000
2022-08-06 19:22:35.653 - debug: netatmo.0 (3501186) States create System PubSub Client
2022-08-06 19:22:35.655 - debug: netatmo.0 (3501186) States create User PubSub Client
2022-08-06 19:22:35.732 - debug: netatmo.0 (3501186) States connected to redis: 127.0.0.1:9000
2022-08-06 19:22:36.029 - debug: netatmo.0 (3501186) Plugin sentry Initialize Plugin (enabled=true)
2022-08-06 19:22:36.588 - info: netatmo.0 (3501186) starting. Version 1.7.1 (non-npm: PArns/ioBroker.netatmo) in /opt/iobroker/node_modules/iobroker.netatmo, node: v16.16.0, js-controller: 4.0.23
2022-08-06 19:22:36.623 - debug: netatmo.0 (3501186) Use individual ID/Secret
2022-08-06 19:22:36.626 - info: netatmo.0 (3501186) Authenticating with Netatmo using individual client-ID ***********************
2022-08-06 19:22:36.627 - info: netatmo.0 (3501186) Try one time fallback authentication with username and password. Might not work after october 2022
2022-08-06 19:22:36.630 - debug: netatmo.0 (3501186) netatmo: authenticate: {"username":"***********","password":"***********","grant_type":"password","client_id":"***********************","client_secret":"***********************","scope":"read_station"}
2022-08-06 19:22:37.078 - debug: netatmo.0 (3501186) netatmo: authenticate err null
2022-08-06 19:22:37.079 - debug: netatmo.0 (3501186) 200
2022-08-06 19:22:37.079 - debug: netatmo.0 (3501186) netatmo: authenticate body {"access_token":"*******************************","refresh_token":"*******************************","scope":["read_station"],"expires_in":10800,"expire_in":10800}
2022-08-06 19:22:37.080 - debug: netatmo.0 (3501186) Access Token: *******************************
2022-08-06 19:22:37.081 - debug: netatmo.0 (3501186) Update Refresh tokens: *******************************
2022-08-06 19:22:37.086 - info: netatmo.0 (3501186) Successfully authenticated with Netatmo with individual client-ID ***********************
2022-08-06 19:22:37.346 - debug: netatmo.0 (3501186) Get Weatherstation data: [{"_id":"**:**:**:**:**:**","station_name":"home","date_setup":1563525061,"last_setup":1563525061,"type":"NAMain","last_status_store":1659805967,"module_name":"room1","firmware":181,"last_upgrade":1563870578,"wifi_status":39,"reachable":true,"co2_calibrating":false,"data_type":["Temperature","CO2","Humidity","Noise","Pressure"],"place":{"altitude":159,"city":"*******","country":"**","timezone":"Europe/Vienna","location":[**.*******,**.*******]},"home_id":"***********************","home_name":"home","dashboard_data":{"time_utc":1659805964,"Temperature":25.6,"CO2":500,"Humidity":55,"Noise":37,"Pressure":1020.3,"AbsolutePressure":1002.1,"min_temp":24.3,"max_temp":26.6,"date_max_temp":1659736988,"date_min_temp":1659777527,"temp_trend":"stable","pressure_trend":"up"},"modules":[{"_id":"**:**:**:**:**:**","type":"NAModule1","module_name":"outdoor","last_setup":1563525100,"data_type":["Temperature","Humidity"],"battery_percent":91,"reachable":true,"firmware":50,"last_message":1659805965,"last_seen":1659805933,"rf_status":70,"battery_vp":5830,"dashboard_data":{"time_utc":1659805933,"Temperature":21.6,"Humidity":65,"min_temp":21.4,"max_temp":27.7,"date_max_temp":1659736976,"date_min_temp":1659777786,"temp_trend":"stable"}},{"_id":"**:**:**:**:**:**","type":"NAModule4","module_name":"room2","last_setup":1544718517,"data_type":["Temperature","CO2","Humidity"],"battery_percent":36,"reachable":true,"firmware":51,"last_message":1659805965,"last_seen":1659805920,"rf_status":66,"battery_vp":4847,"dashboard_data":{"time_utc":1659805920,"Temperature":26.6,"CO2":488,"Humidity":55,"min_temp":25.6,"max_temp":28,"date_max_temp":1659736963,"date_min_temp":1659784746,"temp_trend":"stable"}},{"_id":"**:**:**:**:**:**","type":"NAModule4","module_name":"room3","last_setup":1532156497,"data_type":["Temperature","CO2","Humidity"],"battery_percent":49,"reachable":true,"firmware":51,"last_message":1659805965,"last_seen":1659805946,"rf_status":75,"battery_vp":5074,"dashboard_data":{"time_utc":1659805946,"Temperature":24.2,"CO2":422,"Humidity":59,"min_temp":23.7,"max_temp":26.5,"date_max_temp":1659736937,"date_min_temp":1659778722,"temp_trend":"stable"}}]}]
Cool ... like hoped the "Fallback login with username and password" works. If you restart now then the log shopuld state that "Using stored tokens to initialize" and then username/password are no longer used at all
"Using stored tokens to initialize" -> Correct ;-)
Cool ... so username and passwort are from now on not used anymore