I followed the docs of passport-twitter `
const TwitterStrategy = require("passport-twitter").Strategy
passport.use(new TwitterStrategy({
consumerKey: process.env.TWITTER_CONSUMER_KEY,
consumerSecret: process.env.TWITTER_CONSUMER_SECRET,
callbackURL: "http://localhost:3000/auth/twitter/callback"
},
function(token, tokenSecret, profile, cb) {
User.findOrCreate({ twitterId: profile.id }, function (err, user) {
return cb(err, user);
});
}
));
app.get("/auth/twitter",
passport.authenticate("twitter"));
app.get("/auth/twitter/callback",
passport.authenticate("twitter", { failureRedirect: "/login" }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect("/logged");
});
but I ran with this error:
InternalOAuthError: failed to obtain request token
at /home/joseph/Desktop/vs_code/express/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36
at /home/joseph/Desktop/vs_code/express/node_modules/oauth/lib/oauth.js:543:17
at passBackControl (/home/joseph/Desktop/vs_code/express/node_modules/oauth/lib/oauth.js:397:13)
at IncomingMessage.<anonymous> (/home/joseph/Desktop/vs_code/express/node_modules/oauth/lib/oauth.js:409:9)
at IncomingMessage.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
`
What should I do??
I tried npm audit fix
and npm audit fix --force
and installing npm i passport-twitter
again but it doesn't work. I am using npm: '9.1.2', node: '18.12.1', express 4.16.1