MDL-76002 enrol_lti: let http_client handle form_params option
The lib/lti1p3 library now passes $options['form_params'] instead of $options['body'] when making access token requests. To maintain the 'application/x-www-form-urlencoded' content-type required by OAuth 2.0 (https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3), the client has been changed to convert these array params into a body query string, which matches the behaviour prior to the library upgrade and makes the tool can continue to call tool platform services. Support for $options['body'] remains, as this is still used during service calls.
This commit is contained in:
@@ -65,7 +65,9 @@ class http_client implements IHttpClient {
|
||||
$this->curlclient->setHeader($headers);
|
||||
}
|
||||
if ($method == 'POST') {
|
||||
$res = $this->curlclient->post($url, $options['body'] ?? null, ['CURLOPT_HEADER' => 1]);
|
||||
$body = $options['body'] ?? null;
|
||||
$body = $body ?? (!empty($options['form_params']) ? http_build_query($options['form_params'], '' , '&') : null);
|
||||
$res = $this->curlclient->post($url, $body, ['CURLOPT_HEADER' => 1]);
|
||||
} else if ($method == 'GET') {
|
||||
$res = $this->curlclient->get($url, [], ['CURLOPT_HEADER' => 1]);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user