Sha256: 4ae491ed231b12e1f77761fd4c194907c3ff3245b917c8c007da53fa8903a884

Contents?: true

Size: 842 Bytes

Versions: 4

Compression:

Stored size: 842 Bytes

Contents

# First step of OAuth 2 is getting an authorization code via an authorization grant.
# Then we use the code in a second request to get the access token.
#
# https://tools.ietf.org/html/rfc6749#section-1.3

module BambooId
  module Urls
    module BaseAuthUrl
      def to_s
        [
          base_url,
          param_strings.join('&')
        ].join('?')
      end

      private

      def param_strings
        params.map { |key, value| "#{key}=#{value}" }
      end

      def params
        base_params.merge(additional_params)
      end

      def base_params
        {
          client_id:     client_id,
          scope:         scope,
          response_type: 'code',
          state:         state_code,
          redirect_uri:  redirect_uri
        }
      end

      def additional_params
        {}
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bamboo-id-0.1.3 lib/bamboo_id/urls/base_auth_url.rb
bamboo-id-0.1.2 lib/bamboo_id/urls/base_auth_url.rb
bamboo-id-0.1.1 lib/bamboo_id/urls/base_auth_url.rb
bamboo-id-0.1.0 lib/bamboo_id/urls/base_auth_url.rb