md2googleslides icon indicating copy to clipboard operation
md2googleslides copied to clipboard

Getting a 'Error 400: invalid_request' on first invocation

Open bugok opened this issue 3 years ago • 7 comments

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 avatar Jul 09 '22 18:07 bugok

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 avatar Jul 11 '22 10:07 bugok

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.

bugok avatar Jul 13 '22 07:07 bugok

@bugok any updates on your end?

mlavina avatar Jul 27 '22 14:07 mlavina

@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.

bugok avatar Jul 27 '22 16:07 bugok

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".

k0kubun avatar Aug 30 '22 02:08 k0kubun

@k0kubun: That workaround worked! Thanks!

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

bugok avatar Aug 31 '22 11:08 bugok

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

theluke avatar Feb 20 '23 13:02 theluke