1

oauth2.0 経由でメールを送信するように gmail を設定しようとしています。私はpassport.jsを使用して、ユーザーがGoogle oauth2.0を介してアプリケーションにログインできるようにしています

例:

これらは私が使用したGoogleスコープです:

app.get('/auth/google',
passport.authenticate('google',{ scope: ['https://www.googleapis.com/auth/plus.login','https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile','https://mail.google.com/'],accessType: 'offline', approvalPrompt: 'force' }),
function(req, res){
});

これらは、passport.js と nodemailer トランスポート構成を使用した Google 認証です。

passport.use(new GoogleStrategy({
clientID: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET,
callbackURL: "http://localhost:3000/auth/google/callback"
},
function(accessToken, refreshToken, profile, done) {
transport = nodemailer.createTransport("SMTP", {
    service: 'Gmail',
    auth: {
        XOAuth2: {
            user: profile._json.email,//"example.user@gmail.com",
            clientId: GOOGLE_CLIENT_ID,
            clientSecret: GOOGLE_CLIENT_SECRET,
            refreshToken: refreshToken,
            accessToken: accessToken,
            timeout: 3600
        }
    },
    debug: true
});
process.nextTick(function () {
  return done(null, {
    access_token: accessToken,
    refresh_token: refreshToken,
    profile: profile
  });
});
}
));

メールの送信中にエラーが発生します。エラーは次のとおりです。

SMTP 構成済み

メールを送る

Error occured
{ [Error: connect ETIMEDOUT]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  stage: 'init' }
connect ETIMEDOUT
Closing connection to the server

問題を見つけることができませんでした。誰でも助けることができますか?

4

0 に答える 0