lib/omniauth/strategies/facebook.rb in oa-oauth-0.1.6 vs lib/omniauth/strategies/facebook.rb in oa-oauth-0.2.0.beta1

- old
+ new

@@ -5,19 +5,18 @@ module Strategies # Authenticate to Facebook utilizing OAuth 2.0 and retrieve # basic user information. # # @example Basic Usage - # use OmniAuth::Strategies::Facebook, 'app_id', 'app_secret' + # use OmniAuth::Strategies::Facebook, 'client_id', 'client_secret' class Facebook < OAuth2 # @param [Rack Application] app standard middleware application parameter - # @param [String] app_id the application id as [registered on Facebook](http://www.facebook.com/developers/) - # @param [String] app_secret the application secret as registered on Facebook + # @param [String] client_id the application id as [registered on Facebook](http://www.facebook.com/developers/) + # @param [String] client_secret the application secret as registered on Facebook # @option options [String] :scope ('email,offline_access') comma-separated extended permissions such as `email` and `manage_pages` - def initialize(app, app_id, app_secret, options = {}) - options[:site] = 'https://graph.facebook.com/' - super(app, :facebook, app_id, app_secret, options) + def initialize(app, client_id = nil, client_secret = nil, options = {}, &block) + super(app, :facebook, client_id, client_secret, {:site => 'https://graph.facebook.com/'}, options, &block) end def user_data @data ||= MultiJson.decode(@access_token.get('/me', {}, { "Accept-Language" => "en-us,en;"})) end @@ -28,12 +27,14 @@ end def user_info { 'nickname' => user_data["link"].split('/').last, + 'email' => (user_data["email"] if user_data["email"]), 'first_name' => user_data["first_name"], 'last_name' => user_data["last_name"], 'name' => "#{user_data['first_name']} #{user_data['last_name']}", + 'image' => "http://graph.facebook.com/#{user_data['id']}/picture?type=square", 'urls' => { 'Facebook' => user_data["link"], 'Website' => user_data["website"], } } \ No newline at end of file