How to use the passport-oauth2-refresh.use function in passport-oauth2-refresh

To help you get started, we’ve selected a few passport-oauth2-refresh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmilar / meli-manager / config / meli-auth.js View on Github external
/**
 * Setup mercadolibre passport Strategy.
 *
 * @type {Strategy}
 */
const mercadoLibreStrategy = new MercadoLibreStrategy({
  clientID: clientId,
  clientSecret,
  callbackURL: '/auth/mercadolibre/callback'
},
authorizedCb
)
passport.use(mercadoLibreStrategy)

refresh.use(mercadoLibreStrategy)

// Add promise support to refresh
refresh.requestNewAccessToken = Promise.promisify(refresh.requestNewAccessToken)

module.exports = meliAuth
github gadael / gadael / schema / User.js View on Github external
return new Promise((resolve, reject) => {

            oauthrefresh.use(getStrategy(params.app.config));

            oauthrefresh.requestNewAccessToken('google', user.google.refreshToken, function(err, accessToken, refreshToken) {

                if (err) {
                    return reject(err);
                }

                if (!accessToken) {
                    return reject(new Error('refresh google access token give no result'));
                }

                user.google.accessToken = accessToken;
                if (refreshToken) {
                    // should be the same of the initial refresh token
                    user.google.refreshToken = refreshToken;
                }
github DefinitelyTyped / DefinitelyTyped / types / passport-oauth2-refresh / passport-oauth2-refresh-tests.ts View on Github external
const strategyOptions1: StrategyOptions = {
    authorizationURL: 'http://www.example.com/auth',
    callbackURL: 'http://www.example.com/callback',
    clientID: 'dummy',
    clientSecret: 'secret',
    tokenURL: 'http://www.example.com/token'
};

function verifyFunction1(_accessToken: string, _refreshToken: string, _profile: any, verifyCallback: VerifyCallback) {
    verifyCallback(new Error('unimplemented'));
}

const strategy1: OAuth2Strategy = new OAuth2Strategy(strategyOptions1, verifyFunction1);

use('strategy1', strategy1);

requestNewAccessToken('strategy1', 'exampleRefreshToken', (err, accessToken, refreshToken, results) => {});
requestNewAccessToken('strategy1', 'exampleRefreshToken', {}, (err, accessToken, refreshToken, results) => {});
github freeCodeCamp / meeting-for-good / server / auth / google / passport.js View on Github external
export const setup = (User, config) => {
  passport.use(strategy(User, config));
  refresh.use(strategy(User, config));
};
github Makeshift / eve-goons-waitlist / index.js View on Github external
done(success);
				}
			});
		});

	passport.serializeUser(function (user, done) {
		done(null, user);
	});

	passport.deserializeUser(function (user, done) {
		done(null, user);
	});

	//Extend some stuff
	passport.use('provider', oauthStrategy);
	refresh.use('provider', oauthStrategy);
	app.use(session({
		store: new mongoStore({ db: database.db }),
		secret: setup.data.sessionSecret,
		cookie: { maxAge: 604800 * 1000 }, //Week long cookies for week long incursions!
    resave: true,
    saveUninitialized: true
	}))

	app.use(cookieParser());
	app.use(session({ secret: setup.data.sessionSecret }));
	app.use(flash({ locals: 'flash' }));
	app.use(passport.initialize());
	app.use(passport.session());
	app.use(bodyParser.urlencoded({ extended: true }));
	app.use('/includes', express.static('public/includes'));
	app.use(users.updateUserSession); //Force the session to update from DB on every page load because sessions are not the source of truth here!
github amitava82 / radiole / server / lib / core / passport.js View on Github external
e => cb(e)
                )
            }
        });
    }

    var spotify = new SpotifyStrategy({
            clientID: config.get('auth.spotify.clientId'),
            clientSecret: config.get('auth.spotify.clientSecret'),
            callbackURL: callbackUrl('spotify')
        }, _callback
    );

    passport.use(spotify);

    refresh.use(spotify);

    passport.serializeUser(function(user, cb) {
        cb(null, user._id);
    });

    passport.deserializeUser(function(id, cb) {
        var User = deps.models.User;
        User.findById(id).select('+access_token').lean().exec(cb);
    });

    return passport;
};
github michaelwilcox / headfon.es / server / src / index.ts View on Github external
import { PORT } from './config';

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  context: (req, res) => {
    const { response } = req;
    const { user } = req.request;
    return { response, user };
  }
});

initDatabase();

passport.use(spotifyStrategy);
refresh.use(spotifyStrategy);
passport.use('jwt', jwtStrategy);

server.use(cookieParser());
server.use(bodyParser());
server.use(passport.initialize());

debug(server);

server.use('/auth/connect', middleware.spotify.redirect, () => {});
server.use('/auth/callback', middleware.spotify.base, routes.login);
server.use('/logout', routes.logout);
server.use('/app', middleware.auth, routes.app);
server.use('/user', passport.authenticate(['jwt'], { session: false }), routes.user);
server.use('/token', passport.authenticate(['jwt'], { session: false }), routes.token);

if (process.env.NODE_ENV === 'production') {

passport-oauth2-refresh

A passport.js add-on to provide automatic OAuth 2.0 token refreshing.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis