Как я могу решить ошибку типа, вызывающую сбой приложения heroku? - PullRequest
0 голосов
/ 26 января 2019

Я получаю странную ошибку от heroku, заявляющую: TypeError: OAuth2Strategy требует опции clientID.

Я решил одну ошибку с этим относительно задачи сценария.Я попытался удалить файлы и восстановить все приложение

const passport = require('passport');
const GoogleStrategy = require('passport-google-oauth20').Strategy;
const mongoose = require('mongoose');
const keys = require('../config/keys');
const googleClientID = keys.googleClientID
const googleClientSecret = keys.googleClientSecret
const User = mongoose.model('users');

//Takes user model and passes it into a cookie 
//Use Mongo autogenerated ID
passport.serializeUser((user, done)=>{
done(null, user.id)
});

passport.deserializeUser((id, done)=>{
User.findById(id)
.then((user)=>{
done(null, user);
})
});

// Creates a new instance of google strategy 
// Tells Google how to authenticate Google strategies
passport.use(new GoogleStrategy({

    clientID: googleClientID,
    clientSecret: googleClientSecret, 
    callbackURL: '/auth/google/callback',
    proxy: true
},
//Whenever we reach out to our database it is an asynchronous 
async (accessToken, refreshToken, profile, done ) =>{

const existingUser = await User.findOne({googleID: profile.id})
if(existingUser){
    console.log(profile.emails[0].value)
done(null, existingUser)
}
    const user = await new User({googleID: profile.id, email: profile.emails[0].value, name: profile.displayName}).save()
     done(null, user);




}));
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...