Sha256: 19adf88611778098c5dffe025f8e82fb0dc62c732683b65830990b2be0db4a66

Contents?: true

Size: 857 Bytes

Versions: 6

Compression:

Stored size: 857 Bytes

Contents

module FbGraph
  class Auth
    class VerificationFailed < FbGraph::Exception; end

    attr_accessor :client, :access_token, :user

    def initialize(client_id, client_secret, options = {})
      @client = OAuth2::Client.new(client_id, client_secret, options.merge(
        :site => FbGraph::ROOT_URL
      ))
      if options[:cookie].present?
        from_cookie(options[:cookie])
      end
    end

    def from_cookie(cookie)
      cookie = FbGraph::Auth::Cookie.parse(self.client, cookie)
      self.access_token = OAuth2::AccessToken.new(
        self.client,
        cookie[:access_token],
        cookie[:refresh_token],
        cookie[:expires]
      )
      self.user = FbGraph::User.new(cookie[:uid], :access_token => self.access_token)
      self
    end
  end
end

Dir[File.dirname(__FILE__) + '/auth/*.rb'].each do |file| 
  require file
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fb_graph-0.7.0 lib/fb_graph/auth.rb
fb_graph-0.6.0 lib/fb_graph/auth.rb
fb_graph-0.5.0 lib/fb_graph/auth.rb
fb_graph-0.4.2 lib/fb_graph/auth.rb
fb_graph-0.4.1 lib/fb_graph/auth.rb
fb_graph-0.4.0 lib/fb_graph/auth.rb