Sha256: 0e5b6a6b0dcb35b391a90b25d559e5e2939c64b67032afaaa2ee57fb0f168147

Contents?: true

Size: 871 Bytes

Versions: 3

Compression:

Stored size: 871 Bytes

Contents

module FbGraph2
  class Auth < Rack::OAuth2::Client
    class Grant
      class FbExchangeToken < Rack::OAuth2::Client::Grant
        attr_required :fb_exchange_token
      end
    end

    def initialize(client_id, client_secret, options = {})
      super options.merge(
        identifier: client_id,
        secret: client_secret,
        host: URI.parse(FbGraph2.root_url).host,
        authorization_endpoint: '/oauth/authorize',
        token_endpoint: '/oauth/access_token'
      )
    end

    def fb_exchange_token=(access_token)
      @grant = Grant::FbExchangeToken.new(
        fb_exchange_token: access_token
      )
    end

    def access_token!(options = {})
      super options.merge(
        client_auth_method: :body
      )
    rescue Rack::OAuth2::Client::Error => e
      raise Exception.detect_from_status(e.status).new(e.message)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fb_graph2-0.1.2 lib/fb_graph2/auth.rb
fb_graph2-0.1.1 lib/fb_graph2/auth.rb
fb_graph2-0.1.0 lib/fb_graph2/auth.rb