我已经使用经过测试并在本地工作的Auth0创建了具有用户身份验证的快速应用程序。我曾尝试将我的应用托管在google app引擎上,但是我不确定应该将哪个网址用作.env或设置护照中的回调。我已经用/ callback和http://localhost8080/callback尝试了两个应用程序的url,但是都没有用。
到目前为止,这是我的身份验证和回调路由
router.get('/login', passport.authenticate('auth0', {
scope: 'openid email profile'
}), function (req, res) {
res.redirect('/');
});
router.get('/callback', function (req, res, next) {
passport.authenticate('auth0', function (err, user, info) {
if (err) { return next(err); }
if (!user) { return res.redirect('/login'); }
req.logIn(user, function (err) {
if (err) { return next(err); }
const returnTo = req.session.returnTo;
delete req.session.returnTo;
res.redirect(returnTo || '/');
});
})(req, res, next);
});
然后在app.js中设置我的护照
var strategy = new Auth0Strategy(
{
domain: process.env.AUTH0_DOMAIN,
clientID: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
callbackURL:
'http://localhost:8080/callback'
},
function (accessToken, refreshToken, extraParams, profile, done) {
return done(null, profile);
}
);