Module: Facebook::Access::Helper

Included in:
Facebook::Auth::Devise
Defined in:
lib/facebook/access/helper.rb

Defined Under Namespace

Classes: Decoder

Instance Method Summary collapse

Instance Method Details

#access_token_from_codeObject



9
10
11
# File 'lib/facebook/access/helper.rb', line 9

def access_token_from_code
  session[:oauth].get_access_token(code) 
end

#auth_providerObject



57
58
59
# File 'lib/facebook/access/helper.rb', line 57

def auth_provider
  params[:provider] || 'facebook'
end

#auth_urlObject



39
40
41
# File 'lib/facebook/access/helper.rb', line 39

def auth_url
  @auth_url
end

#cookies_access_tokenObject



25
26
27
# File 'lib/facebook/access/helper.rb', line 25

def cookies_access_token
  @cookies_access_token ||= session[:oauth].(cookies)
end

#fb_appObject



43
44
45
# File 'lib/facebook/access/helper.rb', line 43

def fb_app
  Facebook::App.instance
end

#fb_graphObject



47
48
49
50
51
# File 'lib/facebook/access/helper.rb', line 47

def fb_graph
  @fb_graph ||= graph_api.new session
  log! 'fb_graph', @fb_graph
  @fb_graph
end

#fb_login(permissions = nil) ⇒ Object



13
14
15
16
17
18
# File 'lib/facebook/access/helper.rb', line 13

def  permissions = nil
  session[:oauth] = oauth_api.new(fb_app.identifier, fb_app.secret, fb_app.site_url + fb_app.callback_path)                
  log! 'session-oath', session[:oauth]
  @auth_url =  session[:oauth].url_for_oauth_code(:permissions=> permissions || fb_app.default_permissions)
  log! 'auth_url', @auth_url
end

#fb_login!(permissions = nil) ⇒ Object



20
21
22
23
# File 'lib/facebook/access/helper.rb', line 20

def fb_login! permissions = nil
   permissions
  redirect_to auth_url        
end

#fb_my_idObject



53
54
55
# File 'lib/facebook/access/helper.rb', line 53

def fb_my_id
  @fb_my_id ||= fb_graph.my_id
end

#fb_retrieve_access_tokenObject



4
5
6
7
# File 'lib/facebook/access/helper.rb', line 4

def fb_retrieve_access_token
  session[:access_token] = has_code? ? access_token_from_code : cookies_access_token
  log! 'session-access_token', session[:access_token]
end

#real_time_updatesObject



35
36
37
# File 'lib/facebook/access/helper.rb', line 35

def real_time_updates
  @updates = Facebook.updates_api.new(:app_id => fb_app.identifier, :secret => fb_app.secret)
end

#registrationObject



67
68
69
# File 'lib/facebook/access/helper.rb', line 67

def registration
  signed_request.registration
end

#signed_requestObject

for FB Registration plugin see developers.facebook.com/docs/plugins/registration/



63
64
65
# File 'lib/facebook/access/helper.rb', line 63

def signed_request
  Hashie::Mash.new decoded_signed_request
end

#user_access_tokenObject



29
30
31
32
33
# File 'lib/facebook/access/helper.rb', line 29

def user_access_token
  @user_access_token ||= user_cookie_info["access_token"]
  log! 'user cookie access_token', @user_access_token
  @user_access_token
end