Sha256: d0434ed41b48cca21093fa94ac841f693d3646184478eb27575c5be27e6c5a7f

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

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(e.status, e.response)
    end

    def debug_token!(input_token)
      token_metadata = TokenMetadata.new
      token_metadata.authenticate access_token!
      token_metadata.fetch(
        input_token: input_token.to_s
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fb_graph2-0.4.4 lib/fb_graph2/auth.rb
fb_graph2-0.4.3 lib/fb_graph2/auth.rb
fb_graph2-0.4.1 lib/fb_graph2/auth.rb
fb_graph2-0.4.0 lib/fb_graph2/auth.rb