Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Node.js auth0登录获取id\u令牌_Javascript_Node.js - Fatal编程技术网

Javascript Node.js auth0登录获取id\u令牌

Javascript Node.js auth0登录获取id\u令牌,javascript,node.js,Javascript,Node.js,我是Nodejs和auth0的新手。如果我的问题很愚蠢,我很抱歉。我想要将extraParams.id_令牌保存到会话中(现在我在req.user中有user,我想要类似user.id_toke的东西)。现在我得到了这个错误:无法设置未定义的属性'id\u token' // Configure Passport to use Auth0 var strategy = new Auth0Strategy({ domain: process.env.AU

我是Nodejs和auth0的新手。如果我的问题很愚蠢,我很抱歉。我想要将extraParams.id_令牌保存到会话中(现在我在req.user中有user,我想要类似user.id_toke的东西)。现在我得到了这个错误:无法设置未定义的属性'id\u token'

    // Configure Passport to use Auth0
    var strategy = new Auth0Strategy({
        domain:       process.env.AUTH0_DOMAIN,
        clientID:     process.env.AUTH0_CLIENT_ID,
        clientSecret: process.env.AUTH0_CLIENT_SECRET,
        callbackURL:  'http://localhost:3004/callback'
    }, function(req,accessToken, refreshToken, extraParams, profile, done) {
        // accessToken is the token to call Auth0 API (not needed in the most cases)
        // extraParams.id_token has the JSON Web Token
        // profile has all the information from the user
        req.session.id_token = 'ok';
        return done(null, profile, extraParams);
    });
passport.use(strategy);

// This can be used to keep a smaller payload
passport.serializeUser(function(user, done) {
    done(null, user );
});

passport.deserializeUser(function(user, done) {
    done(null, user);
});

听起来请求对象上不存在
会话
。您是否正确地遵循了Auth0 API?另外,这是该文件中的完整代码,还是有更多的内容?老实说,我发现使用web令牌比使用Auth0更容易实现身份验证建议您先下载node.js快速启动并运行它-大约需要2分钟-特别是如果您从租户处下载快速启动,以便已经为您填充clientId等。