This sounds like MDL-66071 which should be fixed in the Moodle 3.6.5+ weekly release issued 12 days ago.
If your Moodle site is older than this update it to the latest weekly release. (There is a workaround if you can't do this for some reason).
This sounds like MDL-66071 which should be fixed in the Moodle 3.6.5+ weekly release issued 12 days ago.
If your Moodle site is older than this update it to the latest weekly release. (There is a workaround if you can't do this for some reason).
Hi everyone,
I'm asking for help because I have no idea what to do to resolve my problem...
We are tring to set up our moodle instance (installed on a debian VM) to log in via OAuth2 with one of our applications, that is ready to do it (we use it with other apps without any problem)
I've configured moodle with correct client_id, secret, scope... and the next endpoints:
I see in the login page the button with our authentication site, so I click on it
Then, browser open our authentication app and I enter the username and password
When I return to moodle automatically, I get this error:
error/Could not upgrade oauth token
But I dont find any information about this error. There is anyway to get more information about that?
My moodle version is 3.6.1
This error will occur if Moodle's request to the OAuth 2 service token_endpointURL fails.
The most obvious reason for this would be that the URL is wrong so check that first.
The Authenticate token requests via HTTP headers setting should normally be off(the default).
The OAuth 2 service may be logging something in response to this failed request which could help identify the problem.
The failing request causing the error comes from the Moodle web server to the OAuth 2 service (not from the browser) so if it's a Linux server with SELinux is enforcing (check with the command getenforce) you may need to allow Apache to make outgoing network connections if you're using this.
Hi Leon,
Thank you very much for your answer.
I've tried it with Authenticate token requests via HTTP headers setting turned on and turned off without success in both cases. I will keep it turned off.
Where I can see the oAuth service logs? I activated moodle's debbuging and all the information that I can see in the browser is not enough. I didn't see anything in log files in the system and I don't know where I could search for it.
If you're managing your own OAuth 2 service then you may have access to the logs for this. If it's a third party OAuth 2 service then you may not be able to see the logs. Accessing these would be down to the specific OAuth 2 service in use (i.e. I don't know where they are).
If you're comfortable changing the Moodle source code, what I would do next is add some extra output to the error message. You could change line 567 of lib/oauthlib.php from:
throw new moodle_exception('Could not upgrade oauth token');
to (back up up the original file before modifying):
throw new moodle_exception('Could not upgrade oauth token. Code: '
. $this->info['http_code'] . ", response: " .
htmlentities($response));
Hopefully that will show the HTTP status code and any error returned by the OAuth 2 service.
Hello,
I am trying to setup OAuth 2 login feature using LINE (https://developers.line.biz/en/docs/line-login/web/integrate-line-login-v2/) and am having problems. Maybe I am not sending the correct string. I have Facebook and Google OAuth 2 features working, but the third OAuth 2 I want to integrate from LINE is giving me some trouble. I would like some help...
I have both Client ID and Client Secret setup from the LINE side. Below is what I have from Moodle's setup.
When I click on the login link from the login page, the following page shows up-- unlike Google or Facebook which allows you to select the account under which you want to use for login.
Where do I get the URL?
In Moodle 3.5
After login with Saml when a user is logging out and then trying to login again It turns out that the user is still logged in.
The logout is not working/
Hello
I have the Moodle 3.7 stable, https enabled, Google OAuth successful, correct Facebook ID and secret
Then I receive the following message when coming back from Facebook: "The system account was not connected for offline access".
Do you have any idea why that happens? Please help.
I turned on debug and now other message showed up.
Thank you
Giang
Have you checked the mdl_auth_oidc_token table and delete the row for the unsuspended user?
Office suite 3.6.0.1 fixes this.
We are finding that suspended users are not automatically being unsuspended even though they are active in Azure AD.
Any help much appreciated
The 400 Bad Request response is being returned by the OAuth 2 server so it doesn't like the request from Moodle. Does the OAuth app say why it's returning the 400 error?
How can you see the request body? Try changing the line we previously modified to:
throw new moodle_exception('Could not upgrade oauth token. Code: '
. $this->info['http_code'] . ", response: " .
htmlentities($response) .
"body params: " . http_build_query($params));
For example with an invalid token_endpoint on my test site I get:
error/Could not upgrade oauth token. Code: 404, response: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /local/oauth/token.php1 was not found on this server.</p> </body></html> body params: code=bb51b69898a3fd53e489986aed73d336ae8ded70&grant_type=authorization_code&redirect_uri=https%3A%2F%2Foauth20client.example.com%2Fadmin%2Foauth2callback.php&client_id=oauthclient&client_secret=5bff0b…
You can see each parameter Moodle sends in the request separated by '&' starting with "code=bb51b6…". It's a bit messy but it's a quick way to see what Moodle is sending in the request.
Just noting that MDL-66071 is fixed in Moodle 3.6.6 and 3.7.2.