Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- passport.use(new OAuth2Strategy({
- authorizationURL: 'https://www.example.com/oauth2/authorize',
- tokenURL: 'https://www.example.com/oauth2/token',
- clientID: EXAMPLE_CLIENT_ID,
- clientSecret: EXAMPLE_CLIENT_SECRET,
- callbackURL: "http://localhost:3000/auth/example/callback"
- },
- function(accessToken, refreshToken, profile, cb) {
- // Do whatever here with the profile
- }
- ));
- app.get('/auth/example/callback',
- passport.authenticate('oauth2', { failureRedirect: '/login' }),
- function(req, res) {
- // Successful authentication, redirect home.
- res.redirect('/');
- });
- 'use strict';
- var OAuth2 = require('oauth').OAuth2;
- function getTokenFromCode (code, clientID, clientSecret, authorizationURL, tokenURL) {
- return () => {
- var oAuth2 = new OAuth2(clientID, config.clientSecret,
- '', config.authorizationURL, config.tokenURL);
- var _getOAuthAccessToken = oAuth2.getOAuthAccessToken;
- oAuth2.getOAuthAccessToken = (code, params, callback) => {
- if (responseType) {
- params.response_type = responseType;
- }
- _getOAuthAccessToken.call(oAuth2, code, params, callback);
- };
- return oAuth2;
- };
- }
Add Comment
Please, Sign In to add comment