Monthly Archives: November 2011

Save Facebook user data into the database after Authentication using Oauth2

This post is a reply from someone who emailed me, he asked me how to save the user data that already login to our site using facebook graph API.
after we create a login scheme using facebook and oauth2 gem, we need to save the facebook user data to our databases, so.. how to save it into the database?

it’s very easy and simple, when we get a callback from the facebook graph API and save the user data in session like this:

session[:fb_user] = JSON.parse access_token.get(‘/me’)
session[:user] = User.save_user_data(session[:fb_user])

Continue reading