2017-04-10 13 views
0

Passport JSを使用してGoogleから更新トークンを取得できません。私は自分のアカウントのアクセス権を削除して、初めてのログインであることを確認しています。私はトークンの "未定義"を取得し続けます。ここに私が今あるコードがあります。PassportJSとNode.jSを使用してGoogle OAuth 2.0の更新トークンを取得する

Passport.use(new GoogleStrategy({ 
    clientID:  "xxxxx.apps.googleusercontent.com", 
    clientSecret: "xxxxx", 
    callbackURL: `https://localhost:${port}/auth/google/callback`, 
    accessType: 'offline', 
    passReqToCallback: true 
    }, 
    function(req,accessToken, refreshToken, profile, done) { 

    var tokens = { 
     access_token: accessToken, 
     refresh_token: refreshToken 
    } 
    console.log(tokens) 
    oauth2Client.setCredentials(tokens); 


    done(err = false, user = true) 


})); 

、誰もがそれが大幅

答えて

0

答えをいただければ幸いに手を貸すことができ、自分のWebアプリケーションに経験作業のOAuthを持っている場合は、innitailルートの間にそれを要求し、同意プロンプトを毎回作成していました。

app.get('/auth/google', passport.authenticate('google',{accessType: 'offline', prompt: 'consent', scope: ['openid profile email https://www.googleapis.com/auth/drive']})) 
関連する問題