Open
Description
I write app demo just like the example code:
passport.use(new GitHubStrategy({
clientID: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
callbackURL: "http://127.0.0.1:3000/auth/github/callback"
},
function(accessToken, refreshToken, profile, callback) {
return callback(null, {});
}
));
passport.serializeUser((user, done) => {
console.log('serializeUser');
done(null, 1);
});
passport.deserializeUser((id, done) => {
console.log('deserializeUser');
done(null, {});
});
// app.use(helmet());
// app.use(cors());
app.use(express.json());
app.use(session({
store: new MemoryStore({
checkPeriod: 86400000 // prune expired entries every 24h
}),
secret: process.env.SESSION_SECRECT as string,
resave: false,
saveUninitialized: false,
cookie: {
secure: true,
httpOnly: true,
}
}));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(passport.initialize());
app.use(passport.session());
app.get('/auth/github',
passport.authenticate('github'));
app.get('/auth/github/callback',
passport.authenticate('github', { failureRedirect: '/login_failed' }),
function(req, res) {
res.redirect('/');
});
however, when I try to login, I get the error:
TokenError: The client_id and/or client_secret passed are incorrect.
at Strategy.OAuth2Strategy.parseErrorResponse (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-oauth2/lib/strategy.js:358:12)
at Strategy.OAuth2Strategy._createOAuthError (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-oauth2/lib/strategy.js:405:16)
at /Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-oauth2/lib/strategy.js:175:45
at /Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-github/lib/strategy.js:79:16
at /Users/guangyi.li/Desktop/side-project/tenet/node_modules/oauth/lib/oauth2.js:209:7
at passBackControl (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/oauth/lib/oauth2.js:134:9)
at IncomingMessage.<anonymous> (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/oauth/lib/oauth2.js:157:7)
at IncomingMessage.emit (events.js:327:22)
at IncomingMessage.EventEmitter.emit (domain.js:482:12)
at endReadableNT (_stream_readable.js:1221:12)
It seem the issue happened here, the returned access token is undefined:
but I found my github oauth already have one user, and the user also have the oauth app authorized. So what's wrong with my code ?
Metadata
Metadata
Assignees
Labels
No labels