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

Export methods to save oauth tokens between sessions #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hurrymaplelad
Copy link

I'd like to use this library from a backup script, where I can't approve OAuth access each time.

I've added two methods (setAccessToken and dumpAccessToken) to auth once and save the access token.

I use 'em like this:

const gr = goodreads({
  key: settings.GOODREADS_APP_KEY,
  secret: settings.GOODREADS_APP_SECRET
});
gr.initOAuth();
const oauthUrl = await gr.getRequestToken();
console.log(`open ${oauthUrl}`);
console.log(`then press any key to continue`);
await new Promise(resolve => process.stdin.once('data', resolve));
await gr.getAccessToken();
console.log(gr.dumpAccessToken());

Then in future non-interactive runs:

const gr = goodreads({
  key: settings.GOODREADS_APP_KEY,
  secret: settings.GOODREADS_APP_SECRET
});
gr.initOAuth();
gr.setAccessToken({
  token: settings.GOODREADS_OAUTH_TOKEN,
  secret: settings.GOODREADS_OAUTH_SECRET
});

@mshafer
Copy link

mshafer commented Aug 19, 2018

+1 to this PR! I have a similar change on my fork, serving the same purpose (saving tokens between sessions).

@Michael-M-Judd
Copy link

+1 for this

@baahrens
Copy link
Owner

Sorry, took me a while. I'm fine with merging this. Could you resolve the conflicts?

@bscott
Copy link

bscott commented Sep 7, 2020

@hurrymaplelad Can we get the conflicts resolved? so @baahrens can merge :)

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