Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown authentication strategy "wechat" #29

Open
zhaokunyao opened this issue Jan 30, 2024 · 0 comments
Open

Unknown authentication strategy "wechat" #29

zhaokunyao opened this issue Jan 30, 2024 · 0 comments

Comments

@zhaokunyao
Copy link

http://localhost:8080/passport/login/wechat

Error: Unknown authentication strategy "wechat"
at attempt (D:\kr_project\tmp\node_modules\passport\lib\middleware\authenticate.js:193:39)
at authenticate (D:\kr_project\tmp\node_modules\passport\lib\middleware\authenticate.js:379:7)
at Layer.handle [as handle_request] (D:\kr_project\tmp\node_modules\express\lib\router\layer.js:95:5)
at next (D:\kr_project\tmp\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (D:\kr_project\tmp\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (D:\kr_project\tmp\node_modules\express\lib\router\layer.js:95:5)
at D:\kr_project\tmp\node_modules\express\lib\router\index.js:281:22
at Function.process_params (D:\kr_project\tmp\node_modules\express\lib\router\index.js:335:12)
at next (D:\kr_project\tmp\node_modules\express\lib\router\index.js:275:10)
at Function.handle (D:\kr_project\tmp\node_modules\express\lib\router\index.js:174:3)

=======================

`/* login using wechat account */
router.get('/login/wechat', passport.authenticate('wechat'));

/* wechat callback url */
router.get('/oauth2/redirect/wechat',
passport.authenticate('wechat', { failureRedirect: '/?error=wechat_login_failed', failureMessage: true }),
function(req, res) {
console.log('login wechat account success');
res.redirect('/employeeMode');
});

app.js

// configure wechat passport login
var WechatStrategy = require('passport-wechat');
passport.use(new WechatStrategy({
appID: process.env['WECHAT_APP_ID'],
name: 'WeChat',
appSecret: process.env['WECHAT_APP_SECRET'],
client: 'web',
callbackURL: 'http://localhost:8080/passport/oauth2/redirect/wechat',
scope: 'snsapi_base',
state: '123'
// getToken: {getToken},
// saveToken: {saveToken}
},
function(accessToken, refreshToken, profile, done) {
var provider = 'wechat';
return passportHelper.passport_call_back(provider, profile, done, db);
}
));

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant