Sha256: 41703297edaf43ddd27eedd7ad0eca5c51f57d41570fbb2afadcd837afd74c7f

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

module OAuth2
  module Grant
    class Base
      include OAuth2::UrlHelper

      class InvalidAuthorizationTypeError < StandardError; end
  
      attr_accessor :client_id, :client_secret, :connection, :host,
                    :authorize_path, :token_path, :device_path

      def initialize(client)
        @host           = client.host
        @connection     = client.connection
        @client_id      = client.client_id
        @client_secret  = client.client_secret
        @token_path     = client.token_path
        @authorize_path = client.authorize_path
        @device_path    = client.device_path
      end

      def make_request(method, path, opts={})
        if auth_type = opts.delete(:authenticate)
          case auth_type.to_sym
          when :body
            opts[:params] ||= {}
            opts[:params].merge!({
              :client_id     => @client_id,
              :client_secret => @client_secret
            })
          when :headers
            opts[:headers] ||= {}
            opts[:headers]['Authorization'] = http_basic_encode(@client_id, @client_secret)
          else
            #do nothing
          end
        end
        @connection.send_request(method, path, opts)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oauth2-client-1.1.3 lib/oauth2/grant/base.rb
oauth2-client-1.1.2 lib/oauth2/grant/base.rb
oauth2-client-1.1.1 lib/oauth2/grant/base.rb
oauth2-client-1.1.0 lib/oauth2/grant/base.rb
oauth2-client-1.0.0 lib/oauth2/grant/base.rb