Sha256: dfa5454a085b1834fc5a5050bf02147334c9d8f9d4bd6e98b9ba3a030d7b995f

Contents?: true

Size: 802 Bytes

Versions: 9

Compression:

Stored size: 802 Bytes

Contents

module LinkedIn
  module API
    module Authentication
      attr_reader :state

      def authorize_url(params = {})
        params.reverse_merge! config.to_h.slice :scope, :state, :redirect_uri
        params[:scope] = serialize_scope params[:scope]
        auth_code.authorize_url params
      end

      def request_access_token(authorization_code, params = {})
        raise Error::CSRF.new state, params[:state] if params[:state] && params[:state] != state

        params.reverse_merge! redirect_uri: config.redirect_uri
        opts = { mode: :query, param_name: 'oauth2_access_token' }

        self.access_token = auth_code.get_token authorization_code, params, opts
      end

      private

      def serialize_scope(scope)
        Array[scope].flatten.join ' '
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
linkedin2-0.0.16 lib/linkedin/api/authentication.rb
linkedin2-0.0.15 lib/linkedin/api/authentication.rb
linkedin2-0.0.14 lib/linkedin/api/authentication.rb
linkedin2-0.0.13 lib/linkedin/api/authentication.rb
linkedin2-0.0.12 lib/linkedin/api/authentication.rb
linkedin2-0.0.11 lib/linkedin/api/authentication.rb
linkedin2-0.0.10 lib/linkedin/api/authentication.rb
linkedin2-0.0.9 lib/linkedin/api/authentication.rb
linkedin2-0.0.8 lib/linkedin/api/authentication.rb