Passport-Twitter callback not being triggered?

204 Views Asked by At

Okay so I am looking to have the service log in with twitter and everything is working until it goes to the callback url and then what it does is it says 'this webpage isnt available' etc etc, no errors in console. If there is any known solutions to this or a way to get a error to appear for debugging it would be appreciated, thanks.

I have gone as far as downloading pre-made apps and it has the same problem so it must be something on my end.

const app = express();
// middleware stuff (app.use)
.use(session({ secret: 'keyboard cat' }))
.use(bodyParser.urlencoded({extended:false}))
.use(bodyParser.json())
.use(passport.initialize())
.use(passport.session());

// Passport Strategy
passport.use(new TwitterStrategy({
    consumerKey: twitterconsumerkey,
    consumerSecret: twitterconsumersecret,
    callbackURL: "https://www.example.com/auth/twitter/callback"
  },
  function(token, tokenSecret, profile, done) {

  }
));

passport.serializeUser((user, cb) => done(null, user));
passport.deserializeUser((obj, cb) => done(null, obj));

// callback and login
app.get('/auth/twitter', passport.authenticate('twitter'));

app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/' }),
  function(req, res) {
    // Successful authentication, redirect home.
    console.log('hit homepage')
    res.redirect('/');
  });

These are the twitter api callback urls

https://www.example.com/auth/twitter/callback

It should redirect to homepage and output 'hit homepage' into the console but it does not happen.

0

There are 0 best solutions below