fixed ci4s oauth2接入 log

This commit is contained in:
xxq250 2024-10-23 11:41:58 +08:00
parent 04da22ed64
commit 45f597ab47
1 changed files with 10 additions and 1 deletions

View File

@ -31,7 +31,16 @@ module Ci4s::Service
begin begin
Rails.logger.info("[Ci4sOauth] [#{method.to_s.upcase}] #{url} || #{params}") 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) response = client.public_send(method, url, params)
result = JSON.parse(response.body) result = JSON.parse(response.body)