Thanks for posting back with your solution, Emi -it could be helpful to others in future
Same error "error/Could not upgrade oauth token" using a custom external OAuth provider. Any hints as answers above don't seem linked to the inital question ?
I have the same error , OneDrive / DropBox return "error/Could not upgrade oauth token".
it's clear, in the code
if ($this->info['http_code'] !== 200) {
throw new moodle_exception('Could not upgrade oauth token');
}
We have 4 identical web server (same code / same config / share DB) and just one retun this error. If i inspect the request i find this
- Request URL: https://[........]/repository/repository_callback.php?callback=yes&repo_id=258&sesskey=ssJ0VPwCih&oauth2code=M491d5458[........]
- Request Method: GET
- Status Code: 404 Not Found
I don't understant why for this server the callback get 404 error.
After many research, i put somes traces in /lib/oauthlib.php (ln 566).
Trace exemple :
error_log("==== HTTP_CODE : ".$this->info['http_code'], 0); error_log("==== ERROR : ".$this->error, 0); error_log("==== ERRORNO : ".$this->errno, 0); $TypeCode=gettype($this->info['http_code']); error_log("==== type HTTP_CODE : ".$TypeCode, 0);
Return
[07-Nov-2018 08:52:48 America/New_York] ==== HTTP_CODE : 0 [07-Nov-2018 08:52:48 America/New_York] ==== ERROR : couldn't connect to host [07-Nov-2018 08:52:48 America/New_York] ==== ERRORNO : 7 [07-Nov-2018 08:52:48 America/New_York] ==== type HTTP_CODE : integer [07-Nov-2018 08:52:48 America/New_York] Default exception handler: error/Could not upgrade oauth token Debug: Error code: Could not upgrade oauth token
couldn't connect to host caused by a firewall rule.