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

bring your own credentials (issue #64) #74

Merged
merged 7 commits into from
Jun 3, 2021

Conversation

wescpy
Copy link
Contributor

@wescpy wescpy commented Apr 20, 2020

One possible patch for </issues/64> where users are directed to the devconsole/API mgr and download their client ID & secret file as client_id.json. Store it in the same folder as their OAuth token files in ~/. md2googleslides.

@wescpy wescpy requested a review from sqrrrl as a code owner April 20, 2020 09:17
@wescpy wescpy mentioned this pull request Apr 20, 2020
Copy link
Contributor

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super amazing work, works smoothly ❤️

I propose couple of improvements though, let me know what you think. Hopefully, this will help us to have this merged!

I extended your code a little bit here: https://github.com/gsuitedevs/md2googleslides/compare/master...bwplotka:auth?expand=1 and commented here all the feedback.

Hello maintainers! 👋

Is this project maintained? Do you need any help in maintaining this? Is there any communication channel we can discuss where would you need help particularly, what's the vision?

It looks like this is amazing base for further growth and flexibility in defining slides in markdown code... we would love to jump in and start helping more. Looks like people like @wescpy is happy to help as well 🤗

README.md Outdated Show resolved Hide resolved
bin/md2gslides.js Show resolved Hide resolved
Comment on lines +132 to +139
var data; // needs to be scoped outside of try-catch
try {
data = fs.readFileSync(STORED_CLIENT_ID_PATH);
} catch(err) {
return console.log('Error loading client secret file:', err);
}
if(data === undefined) return console.log('Error loading client secret data:', err);
const creds = JSON.parse(data).installed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that might help maintainers to get this merged is focusing on details, let's have this code more resilient. I think we have couple of things we could improve: hugs

  • JSON parsing can error out easily, we should catch those! (:
  • data == undefined is not very helpful. Also at this point we don't have err variable anymore.

Also I am not the super experienced with typescript (Go dev here), is there more idiomatic way to check errors than exceptions? 🤔

What about something like this?

Suggested change
var data; // needs to be scoped outside of try-catch
try {
data = fs.readFileSync(STORED_CLIENT_ID_PATH);
} catch(err) {
return console.log('Error loading client secret file:', err);
}
if(data === undefined) return console.log('Error loading client secret data:', err);
const creds = JSON.parse(data).installed;
var creds;
if (!fs.existsSync(STORED_CLIENT_ID_PATH)) {
return console.log('Client ID + Secret does not exists in path:', STORED_CLIENT_ID_PATH);
}
var data;
try {
data = fs.readFileSync(STORED_CLIENT_ID_PATH);
creds = JSON.parse(data.toString());
} catch (err) {
return console.log('Error loading client secret file:', err);
}

Tried here https://github.com/gsuitedevs/md2googleslides/compare/master...bwplotka:auth?expand=1 and works smoothly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Looks good. The only thing I would change would be to shorten your warning string so line 134 is: return console.log('Credentials file missing from:', STORED_CLIENT_ID_PATH);, and a similar tweak can be made to line 142.

Interesting... your patch is suggesting having a backup of their credentials file (download via long hash name then make a copy w/the short name). Users can also choose to not keep the backup and simply rename the file.

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
@wescpy
Copy link
Contributor Author

wescpy commented Jun 13, 2020

BTW, I'm getting a CI/CD error... when Travis runs, it says,Your lockfile needs to be updated, but yarn was run with --frozen-lockfile. I followed the instructions listed, so should I also commit the updated yarn.lock file to this PR?

@burkestar
Copy link

FWIW I tried these steps (I think I did them correctly) but it still prompts for authorization which is rejected.
image

@wescpy
Copy link
Contributor Author

wescpy commented Oct 7, 2020

I suggest you try it again as at least 2 people (the committers) have used it successfully (and continue to do so... I used it to generate a presentation that was delivered a few weeks ago. Doublecheck you've applied the code patches to your install as it's not just the updated steps for using your own credentials. Hopefully the maintainer will have a free moment to review & accept this PR soon.

@sqrrrl sqrrrl merged commit 9909499 into googleworkspace:master Jun 3, 2021
@wescpy wescpy mentioned this pull request Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants