diff --git a/app/libs/ci4s/service.rb b/app/libs/ci4s/service.rb index c67ccf5b9..ebef5a4c5 100644 --- a/app/libs/ci4s/service.rb +++ b/app/libs/ci4s/service.rb @@ -31,7 +31,16 @@ module Ci4s::Service begin Rails.logger.info("[Ci4sOauth] [#{method.to_s.upcase}] #{url} || #{params}") - client = Faraday.new(url: base_url) + client ||= begin + Faraday.new(url: base_url) do |req| + req.request :url_encoded + req.headers['Content-Type'] = 'application/json' + req.response :logger # 显示日志 + req.adapter Faraday.default_adapter + req.authorization :Bearer, params[:access_token] + req.headers['Authorization'] + end + end response = client.public_send(method, url, params) result = JSON.parse(response.body)