No3x / MMM-GoogleDocs-Notes

:memo: MagicMirror Module to display notes from a Google Doc
MIT License
19 stars 0 forks source link

Trouble with authorization #3

Closed dwburger closed 4 years ago

dwburger commented 4 years ago

Thanks for making this module available. I think it's going to do exactly what I need for my MM2. However, I'm having difficulty with the authorization step. Specifically:

pi@MM2-Office:~/MagicMirror/modules/MMM-GoogleDocs-Notes $ sudo -u pi -- node authorize.js /home/pi/MagicMirror/modules/MMM-GoogleDocs-Notes/authorize.js:40 const clientSecret = credentials.installed.client_secret; ^

TypeError: Cannot read property 'client_secret' of undefined at authorize (/home/pi/MagicMirror/modules/MMM-GoogleDocs-Notes/authorize.js:40:46) at fs.readFile (/home/pi/MagicMirror/modules/MMM-GoogleDocs-Notes/authorize.js:29:3) at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

I followed your instructions carefully and only deviated at one step. On step #9 there was no "other" choice for application type, so I selected "web". "Desktop" was another choice, so maybe I should have selected it??? Anyhow, thanks for any guidance you can provide so I can get this module up and running.

No3x commented 4 years ago

Please follow the steps shown in the video: https://youtu.be/BAHfqwAObag

dwburger commented 4 years ago

Like I said...there is no "other" choice on the "Create OAuth client ID" page for "Application Type". The choices are:

Web application Android Chrome app iOS TV and Limited Input devices Desktop app Universal Windows Platform (UWP)

Which of those needs to be chosen?

No3x commented 4 years ago

As you can see in the video that's how it looks and works for me. If it does not work for you then you probably do something different (what I can't see). I did my best to show you the process.

If you think it's a bug that you can't see this option please contact google. Maybe it is not available for your location or you are not allowed for some reason (I can't tell). Missing information required to provide further help:

dwburger commented 4 years ago

When I went through the process again I selected "Desktop app" and the authorization succeeded.

dwburger commented 4 years ago

I"m getting the module to work on my MM2 and it displays the time stamp for the Google Doc, but the content of the Google Doc is not displayed. The PM2 log shows:

0|mm | [2020-05-09 07:26:31.560] [LOG] 0|mm | [MMM-GoogleDocs-Notes] authorizing... 0|mm | [2020-05-09 07:26:31.565] [LOG] 0|mm | [MMM-GoogleDocs-Notes] printDocContent 0|mm | [2020-05-09 07:26:32.174] [LOG] 0|mm | [MMM-GoogleDocs-Notes] Found 1 documents in drive matching the search 'title starts with MMM'. 0|mm | [2020-05-09 07:26:32.175] [LOG] [MMM-GoogleDocs-Notes] noteDocumentId: 1lUHcufSH_XS1Fk2ySzIBZSPq4jCxVpLS1Pn02XP168k 0|mm | [2020-05-09 07:26:32.427] [LOG]

That, to me, looks like everything's working OK. Any suggestions on why the contents of the Google Doc are not being displayed??? Thanks!

dwburger commented 4 years ago

Update...images in the GoogleDoc are displayed, but not text.

No3x commented 4 years ago

I'm glad to hear the authorization works for you now. But maybe the issue you have is related to it. Maybe you do not have the oauth scopes with this Desktop method. Edit: If images are shown, then reading should work fine.

There should be more output either

[MMM-GoogleDocs-Notes] last modified time of the note

or

[MMM-GoogleDocs-Notes] Failed to ...
dwburger commented 4 years ago

Sorry, I failed to copy all of the PM2 log: 0|mm | [2020-05-09 07:42:01.658] [LOG] 0|mm | [MMM-GoogleDocs-Notes] authorizing... 0|mm | [2020-05-09 07:42:01.662] [LOG] 0|mm | [MMM-GoogleDocs-Notes] printDocContent 0|mm | [2020-05-09 07:42:02.218] [LOG] 0|mm | [MMM-GoogleDocs-Notes] Found 1 documents in drive matching the search 'title starts with MMM'. 0|mm | [2020-05-09 07:42:02.218] [LOG] [MMM-GoogleDocs-Notes] noteDocumentId: 1lUHcufSH_XS1Fk2ySzIBZSPq4jCxVpLS1Pn02XP168k 0|mm | [2020-05-09 07:42:02.513] [LOG] 0|mm | [MMM-GoogleDocs-Notes] last modified time of the note: 2020-05-09T14:39:18.348Z

I will try changing the format of the text to see if I an get it on the display. Any other suggestions???

No3x commented 4 years ago

When you open the node_helper.js file you will see the following lines:

//console.log(`[MMM-GoogleDocs-Notes] doc content of your note: ${content}`);
//console.log(`[MMM-GoogleDocs-Notes] html content of your note: ${htmlContent}`);

please remove the leading // on these lines, save the file and restart the magic mirror. Then share the output again in full length.

No3x commented 4 years ago

Ahh! I think you don't see the output because it's black isn't it? Set the font color to white in google docs. (Please see tip no. 1 in the readme)

dwburger commented 4 years ago

That was it! I changed the text color to yellow and the text displayed nicely. I changed "pollFrequency" to 30 seconds to get rapid updates while solving this issue. It's all working now. I didn't have to change the node_helper.js file. Thank you very much for helping me to get this helpful module working!

dwburger commented 4 years ago

I suspected this MM2 module would be a good addition to my Magic Mirror and I was correct. I'm using it to display a "To Do" list on one mirror and as a message display for another. Thanks again for creating it!