The first portion of the oauth strat works fine, user is redirected to twitch, authorizes, etc... When the callback fires though when the user returns I get the 500 error:
InternalOAuthError: Failed to obtain access token
at Strategy.OAuth2Strategy._createOAuthError (/var/www/html/mc-dev/node-stream/node_modules/passport-oauth2/lib/strategy.js:423:17)
at /var/www/html/mc-dev/node-stream/node_modules/passport-oauth2/lib/strategy.js:177:45
at /var/www/html/mc-dev/node-stream/node_modules/oauth/lib/oauth2.js:191:18
at passBackControl (/var/www/html/mc-dev/node-stream/node_modules/oauth/lib/oauth2.js:132:9)
at IncomingMessage.<anonymous> (/var/www/html/mc-dev/node-stream/node_modules/oauth/lib/oauth2.js:157:7)
at IncomingMessage.emit (events.js:387:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
passport.use(
new twitchStrategy(
{
clientID: process.env.TWITCH_CLIENT_ID,
clientSecret: process.env.TWITCH_CLIENT_SECRET,
callbackURL: process.env.TWITCH_CALLBACK_URL,
scope: ["user:read:email", "user:read:broadcast", "user:edit:broadcast"]
},
(accessToken, refreshToken, profile, done) => {
console.log(profile);
return done(null, profile);
// console.log(accessToken);
// console.log(refreshToken);
}
)
);
router.get('/twitch',
passport.authenticate('twitch.js', { scope: ["user:read:email", "channel:manage:broadcast"] })
);
router.get('/twitch/callback',
passport.authenticate('twitch.js', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});