Sha256: cf3f2dbd32699c753df07541fdc4375d7521a227628675b91d914e9242b92ba5

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

module OAuth2
  module Strategy
    class Base #:nodoc:
      def initialize(client)#:nodoc:
        @client = client
      end

      def authorize_url(options={}) #:nodoc:
        @client.authorize_url(authorize_params(options))
      end

      def authorize_params(options={}) #:nodoc:
        options = options.inject({}){|h, (k, v)| h[k.to_s] = v; h}
        {'client_id' => @client.id}.merge(options)
      end

      def access_token_url(options={})
        @client.access_token_url(access_token_params(options))
      end

      def access_token_params(options={})
        return default_params(options)
      end

      def refresh_token_params(options={})
        return default_params(options)
      end

      private
      def default_params(options={})
        {
          'client_id' => @client.id,
          'client_secret' => @client.secret
        }.merge(options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
panjiva-oauth2-0.4.1 lib/oauth2/strategy/base.rb
oauth2-0.4.1 lib/oauth2/strategy/base.rb
oauth2-0.4.0 lib/oauth2/strategy/base.rb