From 45f597ab47b07ac841e08801d1c451739e220728 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 23 Oct 2024 11:41:58 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20ci4s=20oauth2=E6=8E=A5=E5=85=A5=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/libs/ci4s/service.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)