reddit-oauth-pass-refresh is a wrapper around the Reddit API providing both OAuth and password authentication.
It adds on to the original reddit-oauth by refreshing the access token after expiration even when authenticating with username and password.
npm install reddit-oauth-pass-refresh
var RedditApi = ;var reddit =app_id: 'your_app_id'app_secret: 'your_app_secret'redirect_uri: 'your_app_redirect_uri';// Authenticate with username/password;// Get the OAuth URL to redirect users to// Scopes are defined here:reddit;// After the user is redirected back to us, grab the query string// object and exchange it for a set of access and refresh tokens.// Scope has to be identical as the one provided to oAuthUrl. Can// change for each authentication attempt.;// Returns true if access token existsreddit;// Force a refresh of the access token using the refresh token;// Call authenticated GET endpoint;// Call authenticated GET listing endpoint with easy pagination;// Call authenticated POST endpoint;
Tests written with mocha.
test/config.json and add your own app and user credentials. Then run:
Documentation can be generated with jsdoc by running:
npm run docs