MDL-70282 oauth: Improve error information
If the request to the OAuth 2 token endpoint fails show the response body the endpoint returned with its HTTP status (when debug: DEVELOPER). If no response is available show any error returned by Curl. Previously none of this information was available making troubleshooting difficult. If a token refresh fails in \core\oauth2\refresh_system_tokens_task an exception is now thrown so that the result is shown as "Fail" on admin/tasklogs.php?filter=core\oauth2\refresh_system_tokens_task
This commit is contained in:
@@ -403,7 +403,8 @@ class client extends \oauth2_client {
|
||||
}
|
||||
|
||||
if ($this->info['http_code'] !== 200) {
|
||||
throw new moodle_exception('Could not upgrade oauth token');
|
||||
$debuginfo = !empty($this->error) ? $this->error : $response;
|
||||
throw new moodle_exception('oauth2refreshtokenerror', 'core_error', '', $this->info['http_code'], $debuginfo);
|
||||
}
|
||||
|
||||
$r = json_decode($response);
|
||||
|
||||
Reference in New Issue
Block a user