ruby-on-railsrubyfacebookfacebooker2

Save access_token


I am using facebooker2 that uses Mogli for Facebook Authentication and I would like to save the created access_token to the database. Its already saving the access_token to the created cookie but I would like to save it to the database as well. Is that possible? Can anyone provide an example?

Thanks.


Solution

  • Facebooker2 provides the method current_facebook_client, which you can use from a controller to obtain the access_token and then save it to the database (e.g.: a fb_access_token field of the User model):

    at = current_facebook_client.access_token
    current_user.update_attribute(:fb_access_token, at)