Sha256: 415d0045f9be087fdbd3e1e00155d2fffb3ea98b3b9ad946559339bae524a202

Contents?: true

Size: 1.18 KB

Versions: 11

Compression:

Stored size: 1.18 KB

Contents

module OAuth2
  module Strategy
    # The Authorization Code Strategy
    #
    # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.1
    class AuthCode < Base
      # The required query parameters for the authorize URL
      #
      # @param [Hash] params additional query parameters
      def authorize_params(params = {})
        params.merge('response_type' => 'code', 'client_id' => @client.id)
      end

      # The authorization URL endpoint of the provider
      #
      # @param [Hash] params additional query parameters for the URL
      def authorize_url(params = {})
        @client.authorize_url(authorize_params.merge(params))
      end

      # Retrieve an access token given the specified validation code.
      #
      # @param [String] code The Authorization Code value
      # @param [Hash] params additional params
      # @param [Hash] opts options
      # @note that you must also provide a :redirect_uri with most OAuth 2.0 providers
      def get_token(code, params = {}, opts = {})
        params = {'grant_type' => 'authorization_code', 'code' => code}.merge(@client.redirection_params).merge(params)

        @client.get_token(params, opts)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
oauth2-1.4.8 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.7 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.6 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.5 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.4 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.3 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.2 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.1 lib/oauth2/strategy/auth_code.rb
oauth2-1.4.0 lib/oauth2/strategy/auth_code.rb
oauth2-1.3.1 lib/oauth2/strategy/auth_code.rb
oauth2-1.3.0 lib/oauth2/strategy/auth_code.rb