.

Monday, August 9, 2010

Rails Gem for usage for Facebook OAuth 2.0

def user_from_facebook(cookie_info)
# Create a AccessToken based on the users access_token from the cookie
facebook = OAuth2::AccessToken.new(FacebookGraph, cookie_info['access_token'])
begin
# Fetch user data from Facebook
fb_info = JSON.parse(facebook.get('/me'))
# Check if the access token is for the given user
raise "Received wrong user from facebook"
unless fb_info['id'] == cookie_info['uid']
fb_info['facebook_uid'] = fb_info.delete('id')
return fb_info
rescue Exception => exc
logger.warn "Token verification failed for #{cookie_info.inspect} from #{request.remote_ip}, reason: #{exc}"
end
end

1 comments:

Anonymous said...

Hello, I log on to your new stuff on a regular basis.
Your writing style is awesome, keep up the good work!



my page raspberry ketone diet

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons