dolanmiu / MMM-Monzo

Display Monzo to MagicMirror
MIT License
1 stars 0 forks source link

Cannot get the "refresh_token" #1

Closed SeLLeRoNe closed 6 years ago

SeLLeRoNe commented 6 years ago

Hi, I am trying to install this module on my testbox for Magic Mirror and once I reach the point to get the refresh_token the script token-helper fail.

First it has an error on line 8: "- Be sure to set the return URL as 'http://localhost:8080/oauth' in the Monzo Developer portal", should be "- Be sure to set the return URL as 'http://localhost:8080/oauth' in the Monzo Developer portal,"

Now I am receiving a different error but I don't know how to fix it:

`>npm run token-helper

mmm-monzo@1.0.0 token-helper /home/test/MagicMirror/modules/MMM-Monzo node token-helper/token-helper.js

/home/test/MagicMirror/modules/MMM-Monzo/token-helper/token-helper.js:15 async function doWork() { ^^^^^^^^

SyntaxError: Unexpected token function at createScript (vm.js:56:10) at Object.runInThisContext (vm.js:97:10) at Module._compile (module.js:549:28) at Object.Module._extensions..js (module.js:586:10) at Module.load (module.js:494:32) at tryModuleLoad (module.js:453:12) at Function.Module._load (module.js:445:3) at Module.runMain (module.js:611:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:160:9)

npm ERR! Linux 3.10.0-862.3.3.el7.x86_64 npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "token-helper" npm ERR! node v6.14.2 npm ERR! npm v3.10.10 npm ERR! code ELIFECYCLE npm ERR! mmm-monzo@1.0.0 token-helper: node token-helper/token-helper.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the mmm-monzo@1.0.0 token-helper script 'node token-helper/token-helper.js'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the mmm-monzo package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node token-helper/token-helper.js npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs mmm-monzo npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls mmm-monzo npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /home/test/MagicMirror/modules/MMM-Monzo/npm-debug.log `

This is the content of npm-debug.log cat npm-debug.log 0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'token-helper' ] 2 info using npm@3.10.10 3 info using node@v6.14.2 4 verbose run-script [ 'pretoken-helper', 'token-helper', 'posttoken-helper' ] 5 info lifecycle mmm-monzo@1.0.0~pretoken-helper: mmm-monzo@1.0.0 6 silly lifecycle mmm-monzo@1.0.0~pretoken-helper: no script for pretoken-helper, continuing 7 info lifecycle mmm-monzo@1.0.0~token-helper: mmm-monzo@1.0.0 8 verbose lifecycle mmm-monzo@1.0.0~token-helper: unsafe-perm in lifecycle true 9 verbose lifecycle mmm-monzo@1.0.0~token-helper: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/test/MagicMirror/modules/MMM-Monzo/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/local/crazynetwork:/opt/dell/srvadmin/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin 10 verbose lifecycle mmm-monzo@1.0.0~token-helper: CWD: /home/test/MagicMirror/modules/MMM-Monzo 11 silly lifecycle mmm-monzo@1.0.0~token-helper: Args: [ '-c', 'node token-helper/token-helper.js' ] 12 silly lifecycle mmm-monzo@1.0.0~token-helper: Returned: code: 1 signal: null 13 info lifecycle mmm-monzo@1.0.0~token-helper: Failed to exec token-helper script 14 verbose stack Error: mmm-monzo@1.0.0 token-helper:node token-helper/token-helper.js 14 verbose stack Exit status 1 14 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at EventEmitter.emit (events.js:191:7) 14 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at ChildProcess.emit (events.js:191:7) 14 verbose stack at maybeClose (internal/child_process.js:920:16) 14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5) 15 verbose pkgid mmm-monzo@1.0.0 16 verbose cwd /home/test/MagicMirror/modules/MMM-Monzo 17 error Linux 3.10.0-862.3.3.el7.x86_64 18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "token-helper" 19 error node v6.14.2 20 error npm v3.10.10 21 error code ELIFECYCLE 22 error mmm-monzo@1.0.0 token-helper:node token-helper/token-helper.js 22 error Exit status 1 23 error Failed at the mmm-monzo@1.0.0 token-helper script 'node token-helper/token-helper.js'. 23 error Make sure you have the latest version of node.js and npm installed. 23 error If you do, this is most likely a problem with the mmm-monzo package, 23 error not with npm itself. 23 error Tell the author that this fails on your system: 23 error node token-helper/token-helper.js 23 error You can get information on how to open an issue for this project with: 23 error npm bugs mmm-monzo 23 error Or if that isn't available, you can get their info via: 23 error npm owner ls mmm-monzo 23 error There is likely additional logging output above. 24 verbose exit [ 1, true ]

Also, on npm install I got some skipped packages npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none was installed.

The first two are optionals, so it's okay, the third one looks important so I installed it manually: npm install ajv@^6.0.0 && npm install (the second npm install is just to reinstall everything now that the dependency are now satisfied)

But that doesn't fix the issue anyway :)

Any hint? :)

Thanks Best regards Andrea

dolanmiu commented 6 years ago

What version of node are you using?

Seems like the async keyword is not supported in your node

Look at this:

https://stackoverflow.com/questions/37815790/syntaxerror-unexpected-token-function-async-await-nodejs

Get Node 8 or something

SeLLeRoNe commented 6 years ago

Hi, thanks about that, yes apparently the EPEL Repository for CentOS 7 provides just Node 6 and if I use the official repository breaks npm, so I guess for now I will just need to wait for EPEL repository to provide Node 8+

Thanks again for your time Best regards Andrea

SeLLeRoNe commented 6 years ago

Hi again, I was actually able to update using nodesouorce, I didn't notice that npm was going to be part of the nodejs package on their repo :)

Now I am facing a new error, when I receive the URL to get the "code" once I put my email to login into Monzo the URL in the email goes to localhost, but even if I go on it from the Raspberry it give the error "Cannot GET /oauth".

I also tried to copy the "code=" part on that URL but it seems to not be working as expected to me: body: { code: 'bad_request.could_not_authenticate', error: 'invalid_request', error_description: 'Could not authenticate with provided credentials', message: 'Could not authenticate with provided credentials' } } }

I am not 100% sure what the problem is, I will keep doing some tests and get back, but if you have any suggestion I will appreciate :)

Thanks

SeLLeRoNe commented 6 years ago

Ok, I have managed to fix it, the script only use "localhost:8080" even if you configure the system to run on different port, I changed the Monzo App to be the standard (even if not correct) url as described and I was able to get the refresh code :)

Thanks for this module :)