No3x / MMM-GoogleDocs-Notes

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

Authorize issue #2

Closed YairHadari closed 2 years ago

YairHadari commented 4 years ago

Hi! Thanks for contributing the plugin to the community! I have created a OAuth 2.0 Client ID and downloaded the file. When running sudo -u pi -- node authorize.js I'm getting the following error:

**/home/pi/MagicMirror/modules/MMM-GoogleDocs-Notes/authorize.js:42
  const redirectUrl = credentials.web.redirect_uris[0];
                                                   ^

TypeError: Cannot read property '0' of undefined
    at authorize (/home/pi/MagicMirror/modules/MMM-GoogleDocs-Notes/authorize.js:42:52)
    at fs.readFile (/home/pi/MagicMirror/modules/MMM-GoogleDocs-Notes/authorize.js:29:3)
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)**

Please note that the file looks like that:

{
    "web": {
        "client_id": "11111111111111111-BBBBBBBBBBBBBBBBBBBBBB.apps.googleusercontent.com",
        "project_id": "api-project-715105725930",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_secret": "AAAAAAAAAAAAA"
    }
}

Regards, Yair

No3x commented 4 years ago

Hi @YairHadari, I don't unterstand the issue because there is no occurrence of credentials.web.redirect_uris[0] in my code.

No3x commented 4 years ago

My client_secret.json has an installed key as root element. Did you somehow make a search and replace from installed to web by accident? 😄 It looks like this:

{
    "installed": {
        "client_id": "3333333333-blabla.apps.googleusercontent.com",
        "project_id": "my-project-xxxx",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_secret": "mysecret",
        "redirect_uris": [
            "urn:ietf:wg:oauth:2.0:oob",
            "http://localhost"
        ]
    }
}
YairHadari commented 4 years ago

The script is getting the web keyword from Google json. I have attached previously the content of the file.

Thanks Yair

On Mon, 23 Mar 2020, 19:21 Christian Zöller, notifications@github.com wrote:

Hi @YairHadari https://github.com/YairHadari, I don't unterstand the issue because there is no occurrence of credentials.web.redirect_uris[0] in my code.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/No3x/MMM-GoogleDocs-Notes/issues/2#issuecomment-602740881, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ425WWAJ3XNEFERCH5UUDRI6LDBANCNFSM4LQ7UHFQ .

No3x commented 4 years ago

The script is getting the web keyword from Google json. I have attached previously the content of the file.

This doesn't explain the code change const redirectUrl = credentials.web.redirect_uris[0];.

I was able to reproduce the creation of a client_secret with type web by selecting the wrong type. Please follow the instructions in the readme.

Select the Credentials tab, click the Create credentials button and select OAuth client ID. Select the application type Other Enter the name Magic Mirror Notes. It is important that this matches exactly.

image

YairHadari commented 4 years ago

Thanks Christian!

I have succeed granting permission and got the MMM-GoogleDocs-Notes is authorized note. I have created a document with the name MMM but unfortunately I"m getting a black screen with the message notes and loading...

[image: image.png]

I will appreciate your assistance.

Thanks, Yair

On Mon, Mar 23, 2020 at 8:52 PM Christian Zöller notifications@github.com wrote:

The script is getting the web keyword from Google json. I have attached previously the content of the file. Thanks Yair … <#m5377638319643505537> On Mon, 23 Mar 2020, 19:21 Christian Zöller, @.***> wrote: Hi @YairHadari https://github.com/YairHadari https://github.com/YairHadari, I don't unterstand the issue because there is no occurrence of credentials.web.redirect_uris[0] in my code. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#2 (comment) https://github.com/No3x/MMM-GoogleDocs-Notes/issues/2#issuecomment-602740881>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ425WWAJ3XNEFERCH5UUDRI6LDBANCNFSM4LQ7UHFQ .

This doesn't explain the code change const redirectUrl = credentials.web.redirect_uris[0];.

I was able to reproduce the creation of a client_secret with type web by selecting the wrong type. Please follow the instructions in the readme.

[image: image] https://user-images.githubusercontent.com/2690708/77352618-c09b6c80-6d3f-11ea-9b93-d9c5be07893a.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/No3x/MMM-GoogleDocs-Notes/issues/2#issuecomment-602790713, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ425REYQC2FFVMZGXVVMTRI6VX5ANCNFSM4LQ7UHFQ .

No3x commented 4 years ago

Sorry I can't reproduce this on the master branch. Please show the log Mine is something like this:

[18:59:39.607] [LOG]    [MMM-GoogleDocs-Notes] authorizing...
[18:59:39.609] [LOG]    [MMM-GoogleDocs-Notes] printDocContent
[18:59:40.191] [LOG]    [MMM-GoogleDocs-Notes] Found 4 documents in drive matching the search 'title starts with MMM'.
[18:59:40.191] [LOG]    [MMM-GoogleDocs-Notes] noteDocumentId: 1-xxxexxxxxxxxxxxxxxxxx
[18:59:40.412] [LOG]    [MMM-GoogleDocs-Notes] last modified time of the note: 2020-01-04T16:09:56.205Z

Please also show your config. You can also try the develop branch which has some improvements beside this.

YairHadari commented 4 years ago

Thanks!!! Where the log located and what is the name of it?

On Wed, 25 Mar 2020, 20:02 Christian Zöller, notifications@github.com wrote:

Sorry I can't reproduce this on the master branch. Please show the log Mine is something like this:

[18:59:39.607] [LOG] [MMM-GoogleDocs-Notes] authorizing... [18:59:39.609] [LOG] [MMM-GoogleDocs-Notes] printDocContent [18:59:40.191] [LOG] [MMM-GoogleDocs-Notes] Found 4 documents in drive matching the search 'title starts with MMM'. [18:59:40.191] [LOG] [MMM-GoogleDocs-Notes] noteDocumentId: 1-xxxexxxxxxxxxxxxxxxxx [18:59:40.412] [LOG] [MMM-GoogleDocs-Notes] last modified time of the note: 2020-01-04T16:09:56.205Z

You can also the the develop branch that has some improvements.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/No3x/MMM-GoogleDocs-Notes/issues/2#issuecomment-603995408, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ425R4XSEROV4I2CL5Y6LRJJBKBANCNFSM4LQ7UHFQ .

No3x commented 4 years ago

The plugin uses default logging mechanism provided by MagicMirror. Depending on your environment you can view that log. Please refer to the MagicMirror documentation. I do not run a Magic Mirror on my own so I don't run it on a RPi or something like that. Therefore I don't know about this pm2 stuff. Instead I just run it on my PC in a bash environment with CygWin on Windows. As last resort I can describe how to setup such a environment but please just try to find the log.

Missing information required to provide further help:

Niklas1191 commented 3 years ago

Thanks!!! Where the log located and what is the name of it?

If you're using pm2 for autostart, then you'll have the log in /home/user/.pm2/logs/mm-out.log. For realtime log use tail -f /home/user/.pm2/logs/mm-out.log