Access to Grafana with nodejs login page

how i can connect to grafana with other application ?
i try with auth.generic_auth but didn’t work
this my config:

[auth.generic_oauth]
enabled = true
name = OAuth
allow_sign_up = true
auth_url = http://localhost:8000/login


this my nodejs login:

router.post(’/login’, function(req,res,next){
let promise = User.findOne({email:req.body.email}).exec();
promise.then(function(doc){
if(doc) {
if(doc.isValid(req.body.password)){
// generate token
let token = jwt.sign(doc.toObject(),‘secret’, {expiresIn : ‘3h’});
return res.cookie(‘cookies_session’,token).status(200).redirect(‘http://localhost:3000/’);
} else {
return res.status(501).json({message:’ Invalid Credentials’});
}
}
else {
return res.status(501).json({message:‘User email is not registered.’})
}
});
promise.catch(function(err){
return res.status(501).json({message:‘Some internal error’});
})
});

my server work, but the question is how grafana can know the user or token