lib/manageiq/api/client/connection.rb in manageiq-api-client-0.3.7 vs lib/manageiq/api/client/connection.rb in manageiq-api-client-0.4.0

- old
+ new

@@ -74,11 +74,11 @@ faraday.options.open_timeout = @connection_options[:open_timeout] if @connection_options[:open_timeout] faraday.options.timeout = @connection_options[:timeout] if @connection_options[:timeout] faraday.response(:logger, client.logger) faraday.use FaradayMiddleware::FollowRedirects, :limit => 3, :standards_compliant => true faraday.adapter(Faraday.default_adapter) # make requests with Net::HTTP - if authentication.token.blank? && authentication.miqtoken.blank? + if authentication.token.blank? && authentication.miqtoken.blank? && authentication.bearer_token.blank? faraday.basic_auth(authentication.user, authentication.password) end end end @@ -88,9 +88,10 @@ begin @error = nil @response = handle.run_request(method.to_sym, api_path(path), nil, nil) do |request| request.headers[:content_type] = CONTENT_TYPE request.headers[:accept] = CONTENT_TYPE + request.headers[:authorization] = "Bearer #{authentication.bearer_token}" unless authentication.bearer_token.blank? request.headers['X-MIQ-Group'] = authentication.group unless authentication.group.blank? request.headers['X-Auth-Token'] = authentication.token unless authentication.token.blank? request.headers['X-MIQ-Token'] = authentication.miqtoken unless authentication.miqtoken.blank? request.params.merge!(params) request.body = yield(block).to_json if block