I got this error while trying to get facebook access_token from node.js server:
{“error”:{“message”:”(#803) Some of the aliases you requested do not exist
: access_token”,”type”:”OAuthException”,”code”:803}}
Following is the code for getting access_token:
var options={
host:'graph.facebook.com',
path:'oauth/access_token?client_id=MYAPPID&redirect_uri=http://127.0.0.1:8000/&client_secret=MYAPPSECRET&code=CODEOBTAINEDFROMFB'
}
http.get(options,function(res){
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
Request for the same url from my browser is working fine and I am getting the access_token also. what is the prob here?
Update
This may be the most funniest thing I have experienced from node.js. I have updated the above code as:
var http=require('http')
var options={
host:'grah.facebook.com',
pathname:'/oauth/access_token',
search:'client_id=MYAPPID&redirect_uri=http://127.0.0.1:8000/&client_secret=MYAPPSECRET&code=CODEOBTAINEDFROMFB'
}
http.request(options,function(res){
console.log('http fb code')
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: '+chunk);
});
});
And what happening is server throw an error called socket hang up. Also my network connection(internet connected via mobile modem) breaks out immediately! While Googling this issue I found a lot similar to this, but can’t find the perfect solution…
The problem is with http object. Facebook only allows https while requesting with client_secret.
so this can work as I expected: