passport-facebook icon indicating copy to clipboard operation
passport-facebook copied to clipboard

Unknown authentication strategy "facebook"

Open sajankumar opened this issue 8 years ago • 6 comments

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

sajankumar avatar Sep 05 '16 15:09 sajankumar

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.

ghost avatar Sep 19 '16 14:09 ghost

how can i do this via es6

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

deepakpapola avatar Sep 12 '17 10:09 deepakpapola

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.

BH0 avatar Feb 02 '18 20:02 BH0

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 avatar Aug 29 '19 10:08 surajkkamath

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

surajkkamath avatar Aug 29 '19 10:08 surajkkamath

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();

sumanmahto avatar Sep 07 '19 17:09 sumanmahto