I have successfully used everyauth to implement Facebook connect on my app.
// configure facebook authentication
everyauth.facebook
.appId(config.appId)
.appSecret(config.appSecret)
.handleAuthCallbackError( function (req, res) {
// If a user denies your app, Facebook will redirect the user to
// /auth/facebook/callback?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.
// This configurable route handler defines how you want to respond to
// that.
// If you do not configure this, everyauth renders a default fallback
// view notifying the user that their authentication failed and why.
console.log(res);
})
.findOrCreateUser( function (session, accessToken, accessTokExtra, fbUserMetadata) {
// console.log('session:', session);
// console.log('accessToken:', accessToken);
// console.log('fbUserMetaData:', fbUserMetadata);
return {};
})
.redirectPath('/manager/');
After that, I want to make a few fb graph calls to retrieve some data, for example:
function getFeed(access_token){
var options = {
host: 'graph.facebook.com',
path: '/me/feed/access_token=' + access_token,
method: 'GET'
};
var req = https.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
req.write('data\n');
req.write('data\n');
req.end();
}
If I I call the above fn after user signs in with fb-connect, I expect to be be able to make that call. However, this is the response that I get from FB.
HEADERS: {"access-control-allow-origin":"*","cache-control":"no-store","content-type":"text/javascript; charset=UTF-8","expires":"Sat, 01 Jan 2000 00:00:00 GMT","pragma":"no-cache","www-authenticate":"OAuth \"Facebook Platform\" \"invalid_request\" \"An active access token must be used to query information about the current user.\"","x-fb-rev":"560879","x-fb-debug":"EHNfOK8FGucb250baBLc75M1Id3OY7l+4BxPgj/ZRN0=","date":"Tue, 22 May 2012 05:37:11 GMT","content-length":"140","connection":"keep-alive"}
BODY: {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
message":"An active access token must be used to query information about the current user.
I dont understand this. I have the access_token as the user authenticated my app with facebook-connect. Yet I am unable to retrieve user's feed.
Any explanation would be really helpful.