You can accomplish this using something like Koala . When you authenticate a user, you can grab an access token. Assuming you followed the Devise / Omniauth tutorial , you could do something like this:
def self.find_for_facebook_oauth(response, signed_in_resource=nil) data = response['extra']['user_hash'] access_token = response['credentials']['token'] user = User.find_by_email(data["email"])
Once you have the access token, you can do something like:
@graph = Koala::Facebook::API.new(@user.fb_access_token) profile_image = @graph.get_picture("me")
In my application, I check if the user is registered with a callback from Facebook. If they exist, I assume that the request was associated with accounts. If this is not the case, I assume this is the login.
source share