File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 7
7
oauth2_authorize_url : " "
8
8
oauth2_authorize_signup_url : " "
9
9
oauth2_token_url : " "
10
+ oauth2_token_request_encoding :
11
+ default : " form_encoded"
12
+ type : enum
13
+ choices :
14
+ - form_encoded
15
+ - json
10
16
oauth2_token_url_method :
11
17
default : " POST"
12
18
type : enum
Original file line number Diff line number Diff line change @@ -121,9 +121,10 @@ def register_middleware(omniauth)
121
121
opts [ :client_options ] [ :auth_scheme ] = :request_body
122
122
opts [ :token_params ] = {
123
123
headers : {
124
- "Authorization" => basic_auth_header ,
124
+ "Authorization" => basic_auth_header
125
125
} ,
126
126
}
127
+ opts [ :token_params ] [ :headers ] [ "Content-Type" ] = "application/json" if SiteSetting . oauth2_token_request_encoding == "json"
127
128
elsif SiteSetting . oauth2_send_auth_header?
128
129
opts [ :client_options ] [ :auth_scheme ] = :basic_auth
129
130
else
@@ -141,7 +142,8 @@ def register_middleware(omniauth)
141
142
{ bodies : true , formatter : OAuth2FaradayFormatter }
142
143
end
143
144
144
- builder . request :url_encoded # form-encode POST params
145
+ encoding = SiteSetting . oauth2_token_request_encoding == "form_encoded" ? :url_encoded : :json
146
+ builder . request encoding
145
147
builder . adapter FinalDestination ::FaradayAdapter # make requests with FinalDestination::HTTP
146
148
end
147
149
}
You can’t perform that action at this time.
0 commit comments