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

Problem with authentication in Node.js 20 #184

Closed
derBruti opened this issue Jul 4, 2023 · 25 comments
Closed

Problem with authentication in Node.js 20 #184

derBruti opened this issue Jul 4, 2023 · 25 comments
Labels

Comments

@derBruti
Copy link

derBruti commented Jul 4, 2023

hi,

after upgrade to the newest Adapter Version, Authentication does not work.
I got this error:

OAuth timeout
The OAuth authorization process has timed out. You can close this window now.

Error getting new tokens from Netatmo: Error: Authenticate error: Status code404. Please try again.

Error Log:

image

What can i do?

Thank you!

DerBruti

@Apollon77
Copy link
Collaborator

Welche verison ists denn bei dir? Die "neueste" ist 3.1.0 ist hat ne gaaanz andere Authentication art ... also bitte lesen was im Github readme stahe (und es gab Admin meldungen dazu). Login über Admin-Seite des Adapters neu machen

@derBruti
Copy link
Author

derBruti commented Jul 5, 2023

ich hab die Version 3.1.0.
Das mit dem Login hab ich eigentlich gemacht. Also ich hab mir eine app gemacht und dann die Cllientid und secret ID eingetragen und dann nochmal auf "Authenticate with Netatmo", das klappt alles. aber beim "Callback" kommt irgendwie diese Fehlermeldung. ...
image

@Apollon77
Copy link
Collaborator

What is your admin version

@derBruti
Copy link
Author

derBruti commented Jul 6, 2023

Admin Version 6.4.1

@Apollon77
Copy link
Collaborator

Läuft es auf dem gleichen host wie der Admin oder multi host?

@derBruti
Copy link
Author

derBruti commented Jul 6, 2023

Es läuft auf dem gleichen Host wie der Admin.

@Apollon77
Copy link
Collaborator

Dann ehrlich spontan keine idee. Muss ich mir n bei zeit ansehen. Kannst ja ggf im Forum mal rausfinden ob andere auch das problem haben

@derBruti
Copy link
Author

derBruti commented Jul 6, 2023

Ich werde nochmal im Forum schauen. Bis jetzt hab i No nix gefunden.
Ich danke dir schonmal!

@Apollon77
Copy link
Collaborator

BTW: welche node.js version?

@derBruti
Copy link
Author

derBruti commented Jul 6, 2023

20.3.1.

@Apollon77
Copy link
Collaborator

kannst du mal auf nodejs 18 downgraden?

@derBruti
Copy link
Author

derBruti commented Jul 7, 2023

Ich teste es am Wochenende

@derBruti
Copy link
Author

derBruti commented Jul 9, 2023

also nach einen downgrade, ging es wieder. hab doch zum test nochmal probiert upzugraden, aber ging wieder nicht.
Nach downgrade, ging es wieder.

@Apollon77
Copy link
Collaborator

Da sist jetzt der vierte Fall wo es mit Node.js 20 zu "404" Fehlern bei HTTP kommunikation kommt. Und ja ... jetzt ist es dann wohl mal Zeit den Grund zu finden :(

@Apollon77 Apollon77 changed the title Problem with authentication Problem with authentication in Node.js 20 Jul 9, 2023
@Apollon77
Copy link
Collaborator

PS: Welches OS?

@derBruti
Copy link
Author

derBruti commented Jul 9, 2023

image hilft dir das? wenn du was brauchst, meld dich einfach

@DANSI
Copy link

DANSI commented Jul 17, 2023

Hallo zusammen.
Bei mir funktioniert es ebenfalls nicht.
Grund ist, dass Netatmo wie bereits angekündigt auf den neuen Auth-Mechanismus umgestellt hat.
https://dev.netatmo.com/apidocumentation/oauth#client-credential

!! This method will be deprecated in october 2022 !!
If you want to access data from another user's account, you MUST use the [Authorization code grant type]
https://dev.netatmo.com/apidocumentation/oauth#authorization-code

Also muss das Verfahren zum Verbindungsaufbau mit OAuth umgestellt werden.

Die Jungs von Homebridge haben seit einigen Tagen übrigends die selben Probleme.
New authentification method #62

@winnyschuster
Copy link

@DANSI @derBruti @Apollon77 Könntet ihr mal bitte in der GUI das Sentry abschalten, in den Instanzen rechts das grüne Dreieck klicken so dass es grau wird. Evtl. behebt das den Fehler mit Node20. Bitte Rückmeldung

@Apollon77
Copy link
Collaborator

@DANSI Schau mal im CHangelog, das haben wir im September 2022 getan ... du brauchst also eine aktuelle Adapterversion dann ist DAS an sich nicht das Thema. Das aktuelle Problem scheint ein http-verbindungsproblem mit node.js 20 und Sentry zu sein

@DANSI
Copy link

DANSI commented Jul 24, 2023

@winnyschuster , @Apollon77
Ich habe heute eine neue iobroker-Installation im docker container gestartet.
Darauf läuft nichts anderes als der Netatmo-Adapter.
Nach dem starten des Netatmo-Adapters soll ich mich mit OAuth Authentifizieren
image

Ich hab dann in den Instanzen den Knopf gedrückt
image

Resultat:
image

image

Der Objektbaum bleibt entsprechend leer.
image

Auf einem "allten" iobroker System, welches mit Netatmo verbunden ist, funktioniert derzeit noch alles.

Achja, Sentry ist aus, Problem bleibt.
image

Ich habe dann noch das Loglevel auf "silly" gestellt.
Das OAuth sieht eigentlich ganz gut aus.
-------------------------------------------------------------------------------------------------------------------------
2023-07-24 19:27:49.342 - info: host.iobroker instance system.adapter.netatmo.0 started with pid 3114
2023-07-24 19:27:50.049 - debug: netatmo.0 (3114) Redis Objects: Use Redis connection: 127.0.0.1:9001
2023-07-24 19:27:50.067 - debug: netatmo.0 (3114) Objects client ready ... initialize now
2023-07-24 19:27:50.068 - debug: netatmo.0 (3114) Objects create System PubSub Client
2023-07-24 19:27:50.069 - debug: netatmo.0 (3114) Objects create User PubSub Client
2023-07-24 19:27:50.076 - debug: netatmo.0 (3114) Objects client initialize lua scripts
2023-07-24 19:27:50.080 - debug: netatmo.0 (3114) Objects connected to redis: 127.0.0.1:9001
2023-07-24 19:27:50.082 - silly: netatmo.0 (3114) redis psubscribe cfg.o.system.user.*
2023-07-24 19:27:50.087 - silly: netatmo.0 (3114) redis psubscribe cfg.o.enum.*
2023-07-24 19:27:50.090 - silly: netatmo.0 (3114) objectDB connected
2023-07-24 19:27:50.091 - debug: netatmo.0 (3114) Redis States: Use Redis connection: 127.0.0.1:9000
2023-07-24 19:27:50.094 - debug: netatmo.0 (3114) States create System PubSub Client
2023-07-24 19:27:50.095 - debug: netatmo.0 (3114) States create User PubSub Client
2023-07-24 19:27:50.099 - debug: netatmo.0 (3114) States connected to redis: 127.0.0.1:9000
2023-07-24 19:27:50.099 - silly: netatmo.0 (3114) statesDB connected
2023-07-24 19:27:50.110 - debug: netatmo.0 (3114) Plugin sentry Do not initialize Plugin (enabled=false)
2023-07-24 19:27:50.153 - debug: netatmo.0 (3114) Plugin sentry destroyed because not initialized correctly
2023-07-24 19:27:50.182 - info: netatmo.0 (3114) starting. Version 3.1.0 in /opt/iobroker/node_modules/iobroker.netatmo, node: v18.17.0, js-controller: 4.0.24
2023-07-24 19:27:50.196 - debug: netatmo.0 (3114) Use individual ID/Secret
2023-07-24 19:27:50.197 - info: netatmo.0 (3114) Authenticating with Netatmo using individual client-ID 2qSuvTWBVCDDhd3kn2s2zyxX
2023-07-24 19:27:50.197 - warn: netatmo.0 (3114) API Error: Please Authenticate manually once using the Admin UI of this instance.
2023-07-24 19:27:50.203 - silly: netatmo.0 (3114) States system redis pmessage system.adapter.netatmo.0.logLevel/system.adapter.netatmo.0.logLevel:{"val":"silly","ack":true,"ts":1690219670198,"q":0,"from":"system.adapter.netatmo.0","lc":1690219670198}
2023-07-24 19:27:58.689 - silly: netatmo.0 (3114) States system redis pmessage io.messagebox.system.adapter.netatmo.0/io.messagebox.system.adapter.netatmo.0:{"command":"getOAuthStartLink","message":{"client_id":"2qSuvTWBVCDDhd3kn2s2zyxX","client_secret":"E5fRFrx3cLrTAEkxgXFsmBrXBX79Ykzq","redirect_uri_base":"http://321.321.321.321:8081/","scopes":{"netatmoCoach":false,"netatmoWeather":true,"netatmoWelcome":false,"netatmoSmokedetector":false,"netatmoCOSensor":false,"netatmoDoorBell":false,"netatmoBubendorff":false}},"from":"system.adapter.admin.0","callback":{"message":{"client_id":"2qSuvTWBVCDDhd3kn2s2zyxX","client_secret":"E5fRFrx3cLrTAEkxgXFsmBrXBX79Ykzq","redirect_uri_base":"http://321.321.321.321:8081/","scopes":{"netatmoCoach":false,"netatmoWeather":true,"netatmoWelcome":false,"netatmoSmokedetector":false,"netatmoCOSensor":false,"netatmoDoorBell":false,"netatmoBubendorff":false}},"id":34,"ack":false,"time":1690219678688},"_id":14201751}
2023-07-24 19:27:58.690 - debug: netatmo.0 (3114) Received OAuth start message: {"client_id":"2qSuvTWBVCDDhd3kn2s2zyxX","client_secret":"E5fRFrx3cLrTAEkxgXFsmBrXBX79Ykzq","redirect_uri_base":"http://321.321.321.321:8081/","scopes":{"netatmoCoach":false,"netatmoWeather":true,"netatmoWelcome":false,"netatmoSmokedetector":false,"netatmoCOSensor":false,"netatmoDoorBell":false,"netatmoBubendorff":false}}
2023-07-24 19:27:58.691 - debug: netatmo.0 (3114) Get OAuth start link data: {"client_id":"2qSuvTWBVCDDhd3kn2s2zyxX","client_secret":"E5fRFrx3cLrTAEkxgXFsmBrXBX79Ykzq","scopes":{"netatmoCoach":false,"netatmoWeather":true,"netatmoWelcome":false,"netatmoSmokedetector":false,"netatmoCOSensor":false,"netatmoDoorBell":false,"netatmoBubendorff":false},"scope":"read_station","redirect_uri":"http://321.321.321.321:8081/oauth2_callbacks/netatmo.0/"}
2023-07-24 19:27:58.691 - debug: netatmo.0 (3114) Get OAuth start link: https://api.netatmo.com/oauth2/authorize?client_id=2qSuvTWBVCDDhd3kn2s2zyxX&redirect_uri=http%3A%2F%2F321.321.321.321%3A8081%2Foauth2_callbacks%2Fnetatmo.0%2F&scope=read_station&state=LWB6NbgNfoc52YaiRjLxCchL6i3mSFkraZht1HCU
2023-07-24 19:27:58.692 - silly: netatmo.0 (3114) sendTo "getOAuthStartLink" to system.adapter.admin.0 from system.adapter.netatmo.0
2023-07-24 19:28:01.803 - silly: netatmo.0 (3114) States system redis pmessage io.messagebox.system.adapter.netatmo.0/io.messagebox.system.adapter.netatmo.0:{"command":"oauth2Callback","message":{"state":"LWB6NbgNfoc52YaiRjLxCchL6i3mSFkraZht1HCU","code":"c297dcae0421a61129cf01d6dcc2ffd3"},"from":"system.adapter.admin.0","callback":{"message":{"state":"LWB6NbgNfoc52YaiRjLxCchL6i3mSFkraZht1HCU","code":"c297dcae0421a61129cf01d6dcc2ffd3"},"id":35,"ack":false,"time":1690219681802},"_id":14201752}
2023-07-24 19:28:01.804 - debug: netatmo.0 (3114) OAuthRedirectReceived: {"state":"LWB6NbgNfoc52YaiRjLxCchL6i3mSFkraZht1HCU","code":"c297dcae0421a61129cf01d6dcc2ffd3"}
2023-07-24 19:28:01.805 - debug: netatmo.0 (3114) netatmo: authenticate: {"code":"c297dcae0421a61129cf01d6dcc2ffd3","redirect_uri":"http://321.321.321.321:8081/oauth2_callbacks/netatmo.0/","grant_type":"authorization_code","client_id":"2qSuvTWBVCDDhd3kn2s2zyxX","client_secret":"E5fRFrx3cLrTAEkxgXFsmBrXBX79Ykzq","scope":"read_station"}
2023-07-24 19:28:02.038 - debug: netatmo.0 (3114) netatmo: authenticate err null
2023-07-24 19:28:02.039 - debug: netatmo.0 (3114) netatmo: authenticate status 400
2023-07-24 19:28:02.039 - debug: netatmo.0 (3114) netatmo: authenticate body {"error":"invalid_client"}
2023-07-24 19:28:02.039 - warn: netatmo.0 (3114) API Error: Authenticate error: invalid_client
2023-07-24 19:28:02.040 - error: netatmo.0 (3114) OAuthRedirectReceived: Error: Authenticate error: invalid_client
2023-07-24 19:28:02.040 - silly: netatmo.0 (3114) sendTo "oauth2Callback" to system.adapter.admin.0 from system.adapter.netatmo.0
-------------------------------------------------------------------------------------------------------------------------
*client_id, client_secret und IPAdresse habe ich "nur hier" anonymisiert

@DANSI
Copy link

DANSI commented Jul 24, 2023

Ich habe gerade nochmal bei Netatmo eine neue APP erstellt.
Neue client-id und neue client-secret eingetragen und über den Button in der Instanz authentifiziert.
Jetzt hat alles problemlos funktioniert.
Das würde sich mit der Aussage aus einem anderen Forum decken.
Dort hat es mit einer neuen APP-ID bei Netatmo funktioniert, was bei mir fehl schlug.
Jetzt steh ich natürlich blöd da - geht ja.

Habs gleich nochmal mit der "alten" id probiert. Nun funktionierts dort auch.
Ich hab probiert den Schalter zum Deaktivieren der APP bei Netatmo - hin und her - zu schalten.
image

@Apollon77
Copy link
Collaborator

related getsentry/sentry-javascript#8552

@Apollon77
Copy link
Collaborator

Apollon77 commented Jul 25, 2023

@DANSI When it tells "invalid client id" then please check the client id and secret again. YOur problem ist not the same as the one oin this issue

@benny000004
Copy link

For me the issue was resolved by updating node to 20.8.0 (had 20.5.1 previously).

@Apollon77
Copy link
Collaborator

Then it was caused by the request issues in node.js up to node.js 20.5 ... in fact the bug was fixed in node.js 20.6

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

No branches or pull requests

5 participants