Sha256: 9f6b7d69787e69fa6dd327312f451284d9c68a1dcf475f7f3e0aeafedadde5b0

Contents?: true

Size: 810 Bytes

Versions: 6

Compression:

Stored size: 810 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

require 'fb_graph/auth/cookie'

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fb_graph-1.0.1 lib/fb_graph/auth.rb
fb_graph-1.0.0 lib/fb_graph/auth.rb
fb_graph-0.8.0 lib/fb_graph/auth.rb
fb_graph-0.7.3 lib/fb_graph/auth.rb
fb_graph-0.7.2 lib/fb_graph/auth.rb
fb_graph-0.7.1 lib/fb_graph/auth.rb