Class: RubyApp::Elements::Mobile::Documents::Authentication::Facebook::AuthenticationDocument
- Inherits:
-
AuthenticationDocument
- Object
- RubyApp::Element
- RubyApp::Elements::Mobile::Document
- AuthenticationDocument
- RubyApp::Elements::Mobile::Documents::Authentication::Facebook::AuthenticationDocument
- Defined in:
- lib/ruby_app/elements/mobile/documents/authentication/facebook/authentication_document.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from RubyApp::Elements::Mobile::Document
#links, #metadata, #pages, #scripts, #stylesheets
Attributes inherited from RubyApp::Element
Instance Method Summary collapse
-
#initialize(permissions) ⇒ AuthenticationDocument
constructor
A new instance of AuthenticationDocument.
- #process_token(token) ⇒ Object
Methods inherited from RubyApp::Elements::Mobile::Document
Methods inherited from RubyApp::Element
Methods included from Mixins::ConfigurationMixin
Methods included from Mixins::TranslateMixin
Methods included from Mixins::TemplateMixin
#exclude_parent_template, #exclude_parent_template?, #get_cache, #get_default_template, #get_template, #get_template_name, #get_templates, #template_path
Methods included from Mixins::RenderMixin
#content_for, #get_cache, #get_default_template, #get_templates, #render
Constructor Details
#initialize(permissions) ⇒ AuthenticationDocument
Returns a new instance of AuthenticationDocument.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ruby_app/elements/mobile/documents/authentication/facebook/authentication_document.rb', line 24 def initialize() super() self.page.loaded do |element, event| unless @authentication # RubyApp::Log.debug("FACEBOOK permissions=#{permissions.inspect}") @authentication = ::Koala::Facebook::OAuth.new(ENV['FACEBOOK_ACCESS_KEY'] || RubyApp::Elements::Mobile::Documents::Authentication::Facebook::AuthenticationDocument.configuration.access_key, ENV['FACEBOOK_SECRET_KEY'] || RubyApp::Elements::Mobile::Documents::Authentication::Facebook::AuthenticationDocument.configuration.secret_key, RubyApp::Request.environment[RubyApp::Elements::Mobile::Documents::Authentication::AuthenticationDocument.configuration.return_to]) url = @authentication.url_for_oauth_code(:display => 'touch', :permissions => .is_a?(Array) ? .join(',') : ) RubyApp::Log.info("FACEBOOK --> #{url.inspect}") event.go(url) else RubyApp::Log.info("FACEBOOK <-- #{RubyApp::Request.url.inspect}") code = RubyApp::Request.query['code'] token = @authentication.get_access_token(code) # RubyApp::Log.debug("FACEBOOK token=#{token.inspect}") self.process_token(token) self.hide(event) end end end |
Instance Method Details
#process_token(token) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/ruby_app/elements/mobile/documents/authentication/facebook/authentication_document.rb', line 49 def process_token(token) graph = ::Koala::Facebook::API.new(token) me = graph.get_object('me') # RubyApp::Log.debug("FACEBOOK me=#{me.inspect}") RubyApp::Session.identity = self.create_identity_from_me(me) end |