0

I have everything working correctly including the log in using the Javascript SDK. When the user first goes onto my app they will click to log in to get the initial token and authorize for offline_access.

What I need is that when that user returns it will (in the controller) automatically log them into FB so that I can access their account again WITHOUT having them click the "LogIn to FB" button.

Thanks!

Nate Totten
  • 8,904
  • 1
  • 35
  • 41
dwtera
  • 1
  • 1
  • Do you mean that they're logged out, but when they come in, you'd automatically log them back into facebook? If that's the case, I don't think it's possible, since that would allow intrusion of privacy. – MysticXG Feb 21 '12 at 18:58
  • I am not trying to log them into FB. Maybe I am mistaken and just need to store the "offline_access" auth token that I get back from them? – dwtera Feb 21 '12 at 21:20
  • hm.. well, i don't know much about FB api, so i don't know if this is what you want, but try taking a look here to see if it's what you were looking for http://stackoverflow.com/questions/2687770/do-facebook-oauth-2-0-access-tokens-expire – MysticXG Feb 21 '12 at 21:24
  • Facebook is depreciating the offline_access. https://developers.facebook.com/docs/offline-access-deprecation/ – prabir Feb 22 '12 at 18:24

1 Answers1

2

You will need to do this with the Facebook Javascript SDK. You call the method 'getLoginStatus' when the page loads and you can determine if the user has authorized your app. See: https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    // the user is logged in and has authenticated your
    // app, and response.authResponse supplies
    // the user's ID, a valid access token, a signed
    // request, and the time the access token 
    // and signed request each expire
    var uid = response.authResponse.userID;
    var accessToken = response.authResponse.accessToken;
  } else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    // but has not authenticated your app
  } else {
    // the user isn't logged in to Facebook.
  }
 });
Nate Totten
  • 8,904
  • 1
  • 35
  • 41