Sha256: 45ef2fa609d3c1851925275f32c18679ee4e29c0f6ecd48e8c2f94d1fac2c9d2

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module OAuth2Client
  module Grant
    # Implicit Grant
    # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.2
    class Implicit < Base

      def response_type
        "token"
      end

      # Generate a token path using the given parameters .
      #
      # @param [Hash] query parameters
      def token_path(params={})
        params = params.merge(token_params)
        "#{@authorize_path}?#{to_query(params)}"
      end

      def token_url(params={})
        params = params.merge(token_params)
        build_url(host, :path => authorize_path, :params => params)
      end

      # Retrieve an access token given the specified client.
      #
      # @param [Hash] params additional params
      # @param [Hash] opts options
      def get_token(opts={})
        opts[:params] ||= {}
        opts[:params].merge!(token_params)
        opts[:authenticate] ||= :headers
        method = opts.delete(:method) || :get
        make_request(method, @token_path, opts)
      end

    private

      def token_params
        {
          :response_type => response_type,
          :client_id  => @client_id
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oauth2-client-2.0.0 lib/oauth2-client/grant/implicit.rb