@@ -123,15 +123,14 @@ def register_middleware(omniauth)
123
123
opts [ :scope ] = SiteSetting . oauth2_scope
124
124
end
125
125
126
- if SiteSetting . oauth2_debug_auth && defined? OAuth2FaradayFormatter
127
- opts [ :client_options ] [ :connection_build ] = lambda { | builder |
126
+ opts [ :client_options ] [ :connection_build ] = lambda { | builder |
127
+ if SiteSetting . oauth2_debug_auth && defined? OAuth2FaradayFormatter
128
128
builder . response :logger , Rails . logger , { bodies : true , formatter : OAuth2FaradayFormatter }
129
+ end
129
130
130
- # Default stack:
131
- builder . request :url_encoded # form-encode POST params
132
- builder . adapter Faraday . default_adapter # make requests with Net::HTTP
133
- }
134
- end
131
+ builder . request :url_encoded # form-encode POST params
132
+ builder . adapter FinalDestination ::FaradayAdapter # make requests with FinalDestination::HTTP
133
+ }
135
134
}
136
135
end
137
136
@@ -206,16 +205,14 @@ def log(info)
206
205
207
206
def fetch_user_details ( token , id )
208
207
user_json_url = SiteSetting . oauth2_user_json_url . sub ( ':token' , token . to_s ) . sub ( ':id' , id . to_s )
209
- user_json_method = SiteSetting . oauth2_user_json_url_method
208
+ user_json_method = SiteSetting . oauth2_user_json_url_method . downcase . to_sym
210
209
211
210
log ( "user_json_url: #{ user_json_method } #{ user_json_url } " )
212
211
213
212
bearer_token = "Bearer #{ token } "
214
- connection = Excon . new (
215
- user_json_url ,
216
- headers : { 'Authorization' => bearer_token , 'Accept' => 'application/json' }
217
- )
218
- user_json_response = connection . request ( method : user_json_method )
213
+ connection = Faraday . new { |f | f . adapter FinalDestination ::FaradayAdapter }
214
+ headers = { 'Authorization' => bearer_token , 'Accept' => 'application/json' }
215
+ user_json_response = connection . run_request ( user_json_method , user_json_url , nil , headers )
219
216
220
217
log ( "user_json_response: #{ user_json_response . inspect } " )
221
218
0 commit comments