I am getting a message
Status:400
message: Invalid Client ID
I double checked all my things in the dev page. any help is appreciated.
const Passport = require('passport');
const GoogleStrategy = require('passport-google-oauth20').Strategy;
const twitchStrategy = require("@d-fischer/passport-twitch").Strategy;
require('dotenv').config();
const User = require('../models/user-models');
router.get('/twitch', passport.authenticate('twitch', {
scope: "user_read"
}),
);
// Step 2, Step 3 goes to Passport Setup.js
router.get('/twitch/redirect/' , passport.authenticate('twitch'), (req, res) =>{
console.log("2 req" , req.user);
res.redirect('/profile/');
});
Passport.use (
new twitchStrategy ({
//options for passport
clientID: api_keys.Twitch_ID,
clientSecret : api_keys.Twitch_Secret,
callbackURL: '/auth/twitch/redirect/',
}, (accessToken, refreshToken, profile, done) => {
console.log("5 profile " , profile);
console.log("5b profile " , profile.id);
// done(null, profile);
//callback from passport
//check if user already exists in DB
User.findOne({
TwitchId: profile._json.sub
}).then((currentUser) =>{
if(currentUser)
{
// already in DB from before
console.log("5a");
console.log("Current User is: " + currentUser);
done(null, currentUser);
}
else {
new User ({
username: profile._json.name,
TwitchId: profile._json.sub,
service: 'Twitch'
}).save().then((newUser) =>{
console.log("6");
console.log('new user has been created in db ' + newUser);
done(null, newUser);
});
}
})
}
));