DEV Community

loading...

Couldn't enable facebook authentication via passport-facebook in development mode (localhost)

Vinh Le
・1 min read

Hi all,
I am developing a web app using Facebook authentication. The technologies I used are passport-facebook and express on server side. Specifically:

route.js

   app.get('/auth/facebook', 
      passport.authenticate('facebook', {scope: 'email'} ));

   // 
   app.get('/auth/facebook/callback',
      passport.authenticate('facebook', {
         successRedirect: '/',
         failureRedirect: '/login'
      }));
Enter fullscreen mode Exit fullscreen mode

passport.js

const passport = require('passport');
const FacebookStrategy = require('passport-facebook').Strategy;
const keys = require('../config/keys');

passport.use(new FacebookStrategy({
   clientID: keys.facebookClientID,
   clientSecret: keys.facebookClientSecret,
   callbackURL: '/auth/facebook/callback',
   }, (accessToken, refreshToken, profile, done) => {
      console.log(accessToken, profile);
   }
));

Enter fullscreen mode Exit fullscreen mode

I run the app on development server localhost:3000, when go to route: localhost:3000/auth/facebook, an error message pops up:

"Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https://"

I tried to Google and StackOverFlow this but couldn't find the answer. Would be very appreciate for your helps!
Thanks all & have a great weekend!

Discussion (1)

Collapse
trungducng profile image
Nguyễn Trung Đức • Edited

"Try re-loading the page as https://"". You must serve your route smt like:
https: //localhost:your-port

stackoverflow.com/questions/117449...