I'm developing a node.js app with Facebook login, I'm trying to do unit and integration tests with mocha. So in a function I have this code in order to login:
exports.loginFacebook = function (done){
request({uri:"https://graph.facebook.com//oauth/access_token?client_id={app-id}&client_secret={app-secret}&grant_type=client_credentials",
method: "GET",
timeout: reqOpts.timeout},
function(err, res, body) {
if(err){
throw err;
}
else{
uri2 = "https://graph.facebook.com/APP_ID/accounts/test-users?"+String(body);
request({uri:uri2,
method: "GET",
timeout: reqOpts.timeout},
function(err, res, body) {
if(err){
throw err;
}
else{
login_url = JSON.parse(body).data[0].login_url
console.log(login_url);
request({uri:login_url,
method: "GET",
timeout: reqOpts.timeout},
function(err, res, body) {
if(err){
throw err;
}
else{
request('http://localhost:4004/auth/facebook', reqOpts, function(err, res, body2) {
//console.log(res.statusCode)
//console.log(err)
done()
});
}
});
}
});
}
});
};
Basically I call Facebook API to get the access token, then I list my testing users and I finally I login with the first one. Problem: when I call the login_url, Facebook redirects to this webpage: https://i.stack.imgur.com/nsbkG.jpg ("update your browser"), so I'm not able to do a correct login.
Any ideas how to solve this?
thanks!