jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.29k stars 447 forks source link

Unknown authentication strategy "facebook" #178

Open sajankumar opened 8 years ago

sajankumar commented 8 years ago

i have no clue why is it throwing "Error: Unknown authentication strategy "facebook"" Could anyone help me out?

ghost commented 8 years ago

I believe this usually happens when you fail to configure passport, or fail to pass in your configuration to your main process.

For example, if you have the line passport.use(new Facebook-Strategy({//...}); in your config-passport.js file, but don't include that in your main server file, then you will get this error. An example of properly including it is require('config-passport.js')(passport), where (passport) refers to the passport object.

deepakpapola commented 7 years ago

how can i do this via es6

require('config-passport.js')(passport)

BH0 commented 6 years ago

inside app.js

var app = express(); require('./config/passport')(passport);

Then inside your passport file, wrap the strategy like so:

module.exports = function(passport) { // your passport strategy code } If you don't do the second part you will get an error due to the first part.

Truthfully I'm not sure if this is the official way of doing it but it works for me.

surajkkamath commented 5 years ago

I believe this usually happens when you fail to configure passport, or fail to pass in your configuration to your main process.

For example, if you have the line passport.use(new Facebook-Strategy({//...}); in your config-passport.js file, but don't include that in your main server file, then you will get this error. An example of properly including it is require('config-passport.js')(passport), where (passport) refers to the passport object.

I believe this usually happens when you fail to configure passport, or fail to pass in your configuration to your main process.

For example, if you have the line passport.use(new Facebook-Strategy({//...}); in your config-passport.js file, but don't include that in your main server file, then you will get this error. An example of properly including it is require('config-passport.js')(passport), where (passport) refers to the passport object.

How to do the same in typescript I get error when i use require('config-passport.js')(passport)

surajkkamath commented 5 years ago

How to do the same in typescript I get error when i use require('config-passport.js')(passport)

sumanmahto commented 5 years ago

How to do the same in typescript I get error when i use require('config-passport.js')(passport)

@surajkkamath Whatever you have written in config-passport.ts file, write inside a function like

export default function passportConfig() { }

And import this function and call it in app.ts file

import passportConfig from 'config-passport'; passportConfig();