Sha256: 3be957d689cd74ae54882daebdb0ba40f87546d66a2479f75c95fad6438c293d
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require 'json' module OmniAuth module Strategies # # Authenticate to Facebook utilizing OAuth 2.0 and retrieve # basic user information. # # Usage: # # use OmniAuth::Strategies::Facebook, 'app_id', 'app_secret' # # Options: # # <tt>:scope</tt> :: Extended permissions such as <tt>email</tt> and <tt>offline_access</tt> (which are the defaults). class Facebook < OAuth2 def initialize(app, app_id, app_secret, options = {}) options[:site] = 'https://graph.facebook.com/' super(app, :facebook, app_id, app_secret, options) end def user_data @data ||= JSON.parse(@access_token.get('/me')) end def request_phase(options = {}) options[:scope] ||= "email,offline_access" super(options) end def user_info { 'nickname' => user_data["link"].split('/').last, 'first_name' => user_data["first_name"], 'last_name' => user_data["last_name"], 'name' => "#{user_data['first_name']} #{user_data['last_name']}", 'urls' => { 'Facebook' => user_data["link"], 'Website' => user_data["website"], } } end def auth_hash OmniAuth::Utils.deep_merge(super, { 'uid' => user_data['id'], 'user_info' => user_info, 'extra' => {'user_hash' => user_data} }) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.0.1 | lib/omniauth/strategies/facebook.rb |