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

Authorize issue #2

Open
YairHadari opened this issue Mar 21, 2020 · 8 comments
Open

Authorize issue #2

YairHadari opened this issue Mar 21, 2020 · 8 comments

Comments

@YairHadari
Copy link

@YairHadari YairHadari commented Mar 21, 2020

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

This comment has been minimized.

Copy link
Owner

@No3x No3x commented Mar 23, 2020

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

@No3x

This comment has been minimized.

Copy link
Owner

@No3x No3x commented Mar 23, 2020

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

This comment has been minimized.

Copy link
Author

@YairHadari YairHadari commented Mar 23, 2020

@No3x

This comment has been minimized.

Copy link
Owner

@No3x No3x commented Mar 23, 2020

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

This comment has been minimized.

Copy link
Author

@YairHadari YairHadari commented Mar 24, 2020

@No3x

This comment has been minimized.

Copy link
Owner

@No3x No3x commented Mar 25, 2020

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

This comment has been minimized.

Copy link
Author

@YairHadari YairHadari commented Mar 25, 2020

@No3x

This comment has been minimized.

Copy link
Owner

@No3x No3x commented Mar 25, 2020

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:

  • log
  • config
  • try with develop branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.