passport-facebook
passport-facebook copied to clipboard
Unknown authentication strategy "facebook"
i have no clue why is it throwing "Error: Unknown authentication strategy "facebook"" Could anyone help me out?
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 can i do this via es6
require('config-passport.js')(passport)
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.
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 yourconfig-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 isrequire('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 yourconfig-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 isrequire('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)
How to do the same in typescript I get error when i use require('config-passport.js')(passport)
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();