Class: Authorizme::Provider::Facebook
- Inherits:
-
Object
- Object
- Authorizme::Provider::Facebook
- Defined in:
- lib/authorizme/provider/facebook.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #authorize_with_code(code, redirect_uri) ⇒ Object
- #authorize_with_signed_request(signed_request) ⇒ Object
- #get_access_token ⇒ Object
- #get_client ⇒ Object
- #get_dialog_authorize_url(callback_url, scope) ⇒ Object
- #get_popup_authorize_url(callback_url, scope) ⇒ Object
- #get_signed_request_data ⇒ Object
- #get_user ⇒ Object
- #get_user_json ⇒ Object
-
#initialize(options = {}) ⇒ Facebook
constructor
A new instance of Facebook.
Constructor Details
#initialize(options = {}) ⇒ Facebook
Returns a new instance of Facebook.
9 10 11 12 |
# File 'lib/authorizme/provider/facebook.rb', line 9 def initialize(={}) = init_client end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/authorizme/provider/facebook.rb', line 7 def end |
Instance Method Details
#authorize_with_code(code, redirect_uri) ⇒ Object
51 52 53 54 |
# File 'lib/authorizme/provider/facebook.rb', line 51 def code, redirect_uri @access_token = @client..process_callback(code, :redirect_uri => redirect_uri) return @access_token != nil end |
#authorize_with_signed_request(signed_request) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/authorizme/provider/facebook.rb', line 56 def signed_request @signed_request_data = FBGraph::Canvas.parse_signed_request([:client_secret], signed_request) @access_token = @signed_request_data["oauth_token"] if @signed_request_data["oauth_token"] @client.set_token @access_token if @client return @access_token != nil end |
#get_access_token ⇒ Object
18 19 20 |
# File 'lib/authorizme/provider/facebook.rb', line 18 def get_access_token @access_token end |
#get_client ⇒ Object
14 15 16 |
# File 'lib/authorizme/provider/facebook.rb', line 14 def get_client @client end |
#get_dialog_authorize_url(callback_url, scope) ⇒ Object
69 70 71 |
# File 'lib/authorizme/provider/facebook.rb', line 69 def callback_url, scope "https://www.facebook.com/dialog/oauth/?client_id=#{@options[:client_id]}&redirect_uri=#{CGI.escape(callback_url)}&scope=#{scope}" end |
#get_popup_authorize_url(callback_url, scope) ⇒ Object
63 64 65 66 67 |
# File 'lib/authorizme/provider/facebook.rb', line 63 def callback_url, scope @client..(:redirect_uri => callback_url, :scope => scope, :display => "popup") end |
#get_signed_request_data ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/authorizme/provider/facebook.rb', line 43 def get_signed_request_data if @signed_request_data return @signed_request_data else return nil end end |
#get_user ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/authorizme/provider/facebook.rb', line 26 def get_user user_json = get_user_json if user_json if [:image_size] width = [:image_size][:width] height = [:image_size][:height] image_url = "https://graph.facebook.com/#{user_json.id}/picture?width=#{width}&height=#{height}" else image_url = "https://graph.facebook.com/#{user_json.id}/picture?type=large" end attributes = {first_name: user_json.first_name, last_name: user_json.last_name, image_url: image_url, email: user_json.email} return attributes else return nil end end |
#get_user_json ⇒ Object
22 23 24 |
# File 'lib/authorizme/provider/facebook.rb', line 22 def get_user_json @user_json ||= @client.selection.me.info! if @access_token end |