0

I've been doing user authentication with everyauth and Facebook and all works well. Now, I want to integrate an ability to post to Facebook. Since my app asks only for email scope when users first login, I'll need to get a larger FB scope, and am trying to follow the FB guidelines and only ask for this additional scope when I need it.

I added the following code to my everyauth configuration as per the docs:

everyauth
.facebook
    .appId(conf.fb.appId)
    .appSecret(conf.fb.appSecret)
    //TODO add custom redirect for when authentication is not approved
    .scope(function (req, res) {
        console.log('Setting FB scope');
        console.log('Session: ' + util.inspect(req.session));
        var session = req.session;
        switch (session.userPhase) {
            case 'share-media':
                return 'email,user_status';
            default:
                return 'email';
        }
     })

All is well when an unauthenticated user logs into the application. The problem is that when I want to "up the ante" on FB scope, which I do by setting req.session.userPhase to 'share-media', and then present a link to /auth/facebook to confirm they want to allow posting to FB. When this happens, I get an error that req.session is undefined from the above code (all of req is undefined).

I assume this is since a previously logged-in user is essentially re-authenticating, but isn't that how I would get more scope from Facebook? Am I going about this the wrong way?

Thanks!!!

pat
  • 3,513
  • 3
  • 17
  • 20
  • You can duplicate this error by attempting to load /auth/facebook after you've already logged in. – pat Aug 11 '12 at 13:01
  • I've also tried doing a req.logout() before redirecting to /auth/facebook with no joy. I'm really not sure how to get the additional permissions other than using the FB API directly. Anyone have any ideas??? – pat Aug 12 '12 at 01:43
  • OK, thickening the plot even further, if I authenticate using password authentication, I can then reauthenticate by redirecting to /auth/facebook with my increased permissions. The problem appears to only occur when I first sign on with facebook, then attempt to re-auth with more permissions. I'm hoping someone has an idea here, otherwise I'm wondering if this is a bug. – pat Aug 12 '12 at 20:57

0 Answers0