googleworkspace / md2googleslides

Generate Google Slides from markdown
Apache License 2.0
4.47k stars 283 forks source link

Getting a 'Error 400: invalid_request' on first invocation #170

Open bugok opened 2 years ago

bugok commented 2 years ago

Following the installation instructions in https://github.com/googleworkspace/md2googleslides/issues/95 I was able to get passed the OAuth issue by installing using npm install googleworkspace/md2googleslides, but I hit another issue right after invoking ~/node_modules/md2gslides/bin/md2gslides.js for the first time: Screen Shot 2022-07-09 at 21 32 00

(For searching purposes, I see this text in the bottom part of the error: 'redirect_uri: urn:ietf:wg:oauth:2.0:oob')

I followed the instructions in the README.md file. I've setup a new google cloud project for this, trying to follow the defaults - but maybe I got something wrong there?

Thanks.

bugok commented 2 years ago

Digging into this a little, I found this stack overflow discussion about this, which seems relevant, explaining that this error is because of a deprecated use of OAuth: https://stackoverflow.com/questions/71318804/google-oauth-2-0-failing-with-error-400-invalid-request-for-some-client-id-but

I think the redirect_url isn't right (it's currently set to urn:ietf:wg:oauth:2.0:oob). Does that make sense? What would be a potential fix?

bugok commented 2 years ago

Looking at my ~/.md2googleslides/client_id.json file, I see that the redirect_url field is set to ["http://localhost"], but when I run ~/node_modules/md2gslides/bin/md2gslides.js -n and change the redirect_uris parameter to http://localhost - I get passed the error - but nothing happens - because nothing is running on that host:port.

I think I should generate a credentials with a different redirect_uris - but I'm not sure how to do that.

mlavina commented 2 years ago

@bugok any updates on your end?

bugok commented 2 years ago

@mlavina: No, I couldn't get this to work :( My hunch is that the authentication part of the code could use an update to newer standards - but that's a guess. I'm not sure about this assumption.

k0kubun commented 2 years ago

Digging into this a little, I found this stack overflow discussion about this, which seems relevant, explaining that this error is because of a deprecated use of OAuth: https://stackoverflow.com/questions/71318804/google-oauth-2-0-failing-with-error-400-invalid-request-for-some-client-id-but

The workaround shown in the answer works for md2googleslides too.

Because the problem is coming from urn:ietf:wg:oauth:2.0:oob, you can search the string under node_modules/md2gslides and replace it with http://localhost:1/. In the current main branch, it's here, so I had to modify node_modules/md2gslides/lib/auth.js this time.

Then it will redirect you to http://localhost:1/?code=CODE&scope=..., so you can paste the CODE in the place where md2slides.js asks you to "Enter the code here".

bugok commented 2 years ago

@k0kubun: That workaround worked! Thanks!

(I still think I should keep the issue open, as the current source doesn't seem to work)

theluke commented 1 year ago

Same problem here, I applied the workaround, but I am getting a new error "This App tried to access sensitive content..." App is blocked! Even if you enable the "less secure apps", the error persists