nicholastay / passport-discord

Passport strategy for authentication with Discord (discordapp.com)
ISC License
172 stars 55 forks source link

TokenError: Missing "code_verifier" #59

Open Robz187 opened 6 months ago

Robz187 commented 6 months ago

i am trying to implement the discord strategy to my app and i always get a error after the redirect.

passport.use(new DiscordStrategy({
    clientID: process.env.Discord_ClientID,
    clientSecrete: process.env.Discord_Secrete ,
    callbackURL: process.env.Discord_Callback,
    scope:['identify', 'email']
}, 
async (accessToken,refreshToken,profile, done) => {
    (err,user) => {
        return done(err,user);
   }
}));

app.get("/auth/discord",passport.authenticate('discord'));
app.get('/auth/discord/callback', passport.authenticate('discord', {
    failureRedirect: '/discord/failed',
    successRedirect: process.env.APP_URL 
}));
app.get("/discord/failed",(req,res)=>{
    res.status(401).json({
        error:true,
        message:"Log in failure",
        autherized:false
    });
});
app.get("/discord/worked",(req,res)=>{
    if(req.user){
        res.status(200).json({
            error:false,
            message:"Succes",
            user:req.user,
            autherized:true
        });
    }else{
        res.status(403).json({error:true,message:"Not Authorized"})
    }
});