Skip to content

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.

5 participants