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

fix: netatmo api authentication #182

Merged
merged 10 commits into from
Aug 14, 2023
Merged

fix: netatmo api authentication #182

merged 10 commits into from
Aug 14, 2023

Conversation

CFenner
Copy link
Owner

@CFenner CFenner commented Aug 14, 2023

This changes the authentication method for Netatmo to work with grant_type refresh_token.

Required Changes

We need a refresh_token in the modules configuration instead of username and password. These can be removed.
The refresh_token can be obtained through the Netatmo Apps page. Select your app (see README.md) and scroll down to Token Generator. Choose scope read_station and clock generate token. Copy the refresh token, not the access token, to your config:

{
  module: 'netatmo',
  ...
  config: {
    ...
    refresh_token: 'fill me'
  }
}

fixes #158

@skyhawk180
Copy link

skyhawk180 commented Aug 14, 2023

I am getting the following error after a fresh pull of this module and its now crashing MM.

0|mm     | [14.08.2023 05:31.40.241] [ERROR] (node:15958) UnhandledPromiseRejectionWarning: Error: Cannot find module './api'
0|mm     | Require stack:
0|mm     | - /home/odroid/MagicMirror/modules/netatmo/node_helper.js
0|mm     | - /home/odroid/MagicMirror/js/app.js
0|mm     | - /home/odroid/MagicMirror/js/electron.js
0|mm     | - /home/odroid/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js
0|mm     | - 
0|mm     |     at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
0|mm     |     at n._resolveFilename (node:electron/js2c/browser_init:2:117457)
0|mm     |     at Module._resolveFilename (/home/odroid/MagicMirror/node_modules/module-alias/index.js:49:29)
0|mm     |     at Module._load (node:internal/modules/cjs/loader:927:27)
0|mm     |     at f._load (node:electron/js2c/asar_bundle:2:13330)
0|mm     |     at Module.require (node:internal/modules/cjs/loader:1148:19)
0|mm     |     at require (node:internal/modules/cjs/helpers:110:18)
0|mm     |     at Object.<anonymous> (/home/odroid/MagicMirror/modules/netatmo/node_helper.js:8:13)
0|mm     |     at Module._compile (node:internal/modules/cjs/loader:1269:14)
0|mm     |     at Module._extensions..js (node:internal/modules/cjs/loader:1324:10)
0|mm     |     at Module.load (node:internal/modules/cjs/loader:1124:32)
0|mm     |     at Module._load (node:internal/modules/cjs/loader:965:12)
0|mm     |     at f._load (node:electron/js2c/asar_bundle:2:13330)
0|mm     |     at Module.require (node:internal/modules/cjs/loader:1148:19)
0|mm     |     at require (node:internal/modules/cjs/helpers:110:18)
0|mm     |     at loadModule (/home/odroid/MagicMirror/js/app.js:180:19)
0|mm     | (Use `electron --trace-warnings ...` to show where the warning was created)
0|mm     | [14.08.2023 05:31.40.243] [ERROR] (node:15958) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

@CFenner
Copy link
Owner Author

CFenner commented Aug 14, 2023

@skyhawk180 I think you do not have the most recent version of the code or it could be a cache issue on the mirror.

@CFenner CFenner merged commit 3a9e706 into main Aug 14, 2023
5 of 7 checks passed
@CFenner CFenner deleted the auth branch August 14, 2023 22:50
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

Successfully merging this pull request may close these issues.

Module stopped working
2 participants