Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Nodemailer Google Passport Oauth Strategy

var passport = require('passport'),
    GoogleStrategy = require('./google_oauth2'),
    config = require('../config');

passport.use('google-imap', new GoogleStrategy({
  clientID: config('google.api.client_id'),
  clientSecret: config('google.api.client_secret')
}, function (accessToken, refreshToken, profile, done) {
  console.log(accessToken, refreshToken, profile);
  done(null, {
    access_token: accessToken,
    refresh_token: refreshToken,
    profile: profile
  });
}));

exports.mount = function (app) {
  app.get('/add-imap/:address?', function (req, res, next) {
    passport.authorize('google-imap', {
        scope: [
          'https://mail.google.com/',
          'https://www.googleapis.com/auth/userinfo.email'
        ],
        callbackURL: config('web.vhost') + '/add-imap',
        accessType: 'offline',
        approvalPrompt: 'force',
        loginHint: req.params.address
      })(req, res, function () {
        res.send(req.user);
      });
  });
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: wow.js 
Javascript :: object to string js 
Javascript :: nested callbacks javascript 
Javascript :: arrow functions syntax 
Javascript :: adding more than one class react 
Javascript :: airbnb and eslint react native 
Javascript :: js Destructuring arrays and objects 
Javascript :: why node_modules are not installed anymore 
Javascript :: react component visibility 
Javascript :: filtering an array in javascript 
Javascript :: sequelize attributes exclude all 
Javascript :: link in next js is refresh page 
Javascript :: JavaScript try...catch...finally Statement 
Javascript :: js regular expression 
Javascript :: cast string to int angular 
Javascript :: how to detect click outside input element javascript 
Javascript :: pug to html 
Javascript :: replace spaces with dashes 
Javascript :: var json = $.parseJSON(request.responseText); 
Javascript :: binarysearch 
Javascript :: create file object node js 
Javascript :: ternary javascript 
Javascript :: run only one test cypress 
Javascript :: slice js 
Javascript :: average javascript 
Javascript :: Angular JS Interpolation 
Javascript :: angular flex layout 
Javascript :: Prerequisites before creating react-app 
Javascript :: react npm start not working 
Javascript :: js react 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =