Unknown authentication strategy "github"

Tell us what’s happening:
I’m passing the test cases for the github authentication setup and as I compare my js files with the right answer files I don’t see any difference. However, my app is still failing with the error:Unknown authentication strategy “github”.
Your code so far
https://replit.com/@faridhuseynov/boilerplate-advancednode-1#.env

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36.

Challenge: Implementation of Social Authentication III

Link to the challenge:

Hello there,

Here is the issue:

passport.use(new GitHubStrategy({
  clientID: process.env.GITHUB_CLIENT_ID,
  clientSecret: process.env.GITHUB_CLIENT_SECRET,
  callbackURL: 'https://replit.com/@faridhuseynov/auth/github/callback'

The callbackURL should point to your app. Not, to your app code. Remember, the routes of an app refer to what an end user might see/use.

Look at the example:

passport.use(new GitHubStrategy({
      clientID: process.env.GITHUB_CLIENT_ID,
      clientSecret: process.env.GITHUB_CLIENT_SECRET,
      callbackURL: 'https://boilerplate-advancednode.your-username.repl.co/auth/github/callback'
    },

Hope this clarifies

1 Like

Changed it, still looks as the same error

Would you mind sharing the full error message?


Also, try defining the routes afterwards:

app.route('/auth/github').get(passport.authenticate('github'));

app.route('/auth/github/callback').get(passport.authenticate('github',{failureRedirect:'/'}),(req,res)=>{
  req.session.user_id = req.user.id;
  res.redirect('/chat');
})

Should come after:

  app.route('/login').post(passport.authenticate('local',{failureRedirect:'/'}),function(req,res){
    res.redirect('/profile');
  });

  app.route('/profile').get(ensureAuthenticated, (req,res)=>{
    res.render(__dirname+'/views/pug/profile', {username:req.user.username});
  });

app.route('/chat').get(ensureAuthenticated,(req,res)=>{
  res.render(__dirname+'/views/pug/chat',{user:req.user});
});

Also, considering you have not been told to create the /chat route yet, there may be unexpected errors, if you use the /chat route.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.