Sha256: e1ca7fde0a4c8461bbf70b305fd7118f1099bb7a7b900516e6a68f1a8b616498

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

module OAuth2
  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

5 entries across 5 versions & 1 rubygems

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