Oauth2 problems in Moodle 3.3

Re: Oauth2 problems in Moodle 3.3

by Mary Cooch -
Number of replies: 3
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Thanks for posting back with your solution, Emi -it could be helpful to others in futuresmile

In reply to Mary Cooch

Re: Oauth2 problems in Moodle 3.3

by Jerome Denanot -

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 ? 

In reply to Jerome Denanot

Re: Oauth2 problems in Moodle 3.3

by Aurélien Besson -

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.



In reply to Aurélien Besson

Re: Oauth2 problems in Moodle 3.3

by Aurélien Besson -

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.