-
Notifications
You must be signed in to change notification settings - Fork 12
Description
My callback request always fails with the same error. I am using koa, could it be related to the session configurations? Please tell me if I need to provide extra details, I have tried everything I found relevant with no success.
`router.get("/auth/twitter", (ctx, next) => {
return passport.authenticate(provider, {
scope: ['tweet.read', 'users.read', 'offline.access'],
})(ctx, next);
});
router.get("/auth/twitter/callback", async (ctx, next) => {
await passport.authenticate(provider, function (err, user, info) {
if (err) {
console.log(JSON.stringify(err, null, 2));
ctx.status = 500;
ctx.body = { error: "Internal Server Error" };
return;
}
if (!user) {
ctx.status = 401;
ctx.body = { error: "Authentication failed" };
return;
}
ctx.body = {
access_token: user.accessToken,
refresh_token: user.refreshToken,
profile: user.profile,
};
ctx.status = 200;
})(ctx, next);
});`
Koa server session config:
app.use(passport.initialize()); app.use(session({}, app)); app.use(passport.session());
Also the endpoints above are called from the frontend