Oauth2 authentication plugin for Moodle (for Moodle 3.2 and earlier) icon

Oauth2 authentication plugin for Moodle (for Moodle 3.2 and earlier)

Maintained by Sergio Rabellino
Sign-in with an Oauth2 provider. The first time you sign-in, a new account is created.
Price option: Free

Supports Moodle 2.1-3.2 See all versions
Latest release: 7 years ago
Installations: 416
Downloads (last 90 days): 41

Frankenstyle name: auth_googleoauth2
Authentication
OAuth2

Comments

Comments are no longer open for new posts. Existing comments remain available to read.

I'm hoping someone can help.
I want to use our google apps domain accounts to login to moodle. I have set up this plugin following the instructions but when I click on the "Login with Google" link It prompts me to login to google, which I do but then I get redirected back to the moodle login page asking me for a username and password.
Do I need to disable other login methods for this to work??
I currently authenticate against LDAP and also have the Google SAML plugin enabled. Would this cause any issues?
This is a bad issue. I disabled other authentication method when I used this plugin on my site. Unhappily I don't have time much time to work on it yet. I'm going to add a warning in the plugin description.
You shouldn't use this plugin, it's too much unsafe.
I would like to report a bug. Plugin works fine, but there's a major security failure. If you know a username (for example, using the default prefix "social_user_XX", you'll know every username) then using the classic form to login (not the facebook login button), it won't check if password is right, so, it will let you login with a wrong password. Because of this, I had to disable the plugin. Plase let me know if there's a solution (changing prefix isn't a admissible). Thanks.
I found the answer to my problem (and Mandi's). Simply add hd=domain.com as one of the arguments in the url.
So in your login page html the line will be something like
https://accounts.google.com/o/oauth2/auth?hd=domain.com&client_id=<?php echo get_config('auth/googleoauth2', 'googleclientid'); ?>&redirect_uri=<?php echo $CFG->wwwroot; ?>/auth/googleoauth2/google_redirect.php&scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email&response_type=code">Sign in with Google
Mandi, I'm trying to achieve the same. In moodle you can only allow registration from a specific list of domains - go to admin/settings.php?section=manageauths and find Allowed email domains. What I would like is that when the user clicks on the sign in with Google button, they are taken to our domain specific login screen like you see at google.com/a/domain.com
Hi Jérôme, students.edequal.com,
It seems it refreshes back to Login after loggin in? Could u see whats up? Its 2.5
Hi everybody, i installed the plugin in my moodle. If i log with my personal facebook profile all ok(i'm administrator of google application, facebook application ecc ecc), if i log with any other profile, I visualize this error:
error/facebook_failure
Debug info:
Error code: facebook_failure
$a contents:
Stack trace:
line 11 of /auth/googleoauth2/facebook_redirect.php: moodle_exception thrown
Why???? Please Help meeeeeeeeeee!!!!
Great plugin! Works fine!
Except for one thing:
I have installed both facebook and google+, and with that I got a small problem.
When entering the login screen for the first time, both of the login methods are shown. If I choose Facebook, and login and out again (and make sure I have also logged out of my facebook-session), and return to the login-screen, I can only see one of the login methods.
There is a link "Sign-in with another service" at the bottom, but it doesn't bring up both of the login methods, because it points wrong. It puts the ?allauthproviders=true directly to the main moodle address, without adding the /login/index.php inbetween.
It seems to me that some variable is not validated correctly, so the "/login/index.php" is not added:
./theme/base/layout/login.php:
echo $CFG->wwwroot . (isset($CFG->alternateloginurl) ? $CFG->alternateloginurl : '/login/index.php') . '?allauthproviders=true';
How to restrict the login to only accept authentication requests from users with an email on a specific domain name or set of domain names.
I found this link: http://stackoverflow.com/questions/10858813/restrict-login-email-with-google-oauth2-0-to-specific-domain-name
But don't know how to customize in our case.
Carlos, from memory: copy the layout/general.php into layout/login.php. In config.php, there is a section login with general.php into it, change it for login.php. Then edit layout/login.php. Add the code from the README before the footer. In the code change YOURTHEME for your theme name. Finally copy the GOOGLELOGO.jpg, FACEBOOKLOGO.jpg in the correct folder (the one from the line containing YOURTHEME)
Retested Google oauth2, it works with the most recent unreleased 2.5 (for online sites of course). So it should work on all previous version too.
I'm trying to make this plugin work on a Moodle 2.4.2 (Build: 20130311)
I think I've configured all settings within the authentication section for admins, I also installed the moodlebook theme but I can't get to have the auth login option anywhere… what am I missing?
I read that I should include some php code but couldn't find the file where it should go mixed maybe it's not named that way on my version?
I hope you can help, I have installed the GoogleOauth2 plugin and had it working on a number of my moodle sites, but now with my latest site its failing to work. I keep getting the following error, after I attempt to login for the first time via a Google account.
'The authentication provider sent us a communication error. Please try to sign-in again.' - this is related to the $string['couldnotgetgoogleaccesstoken']
I Have tried signing in numerous times and checked my Google API key and other settings.
Could you suggest why I would be getting this error? and how I could potentially resolve it?
In order to make work this plugin in my moodle 2.3.1
I changed only one line in googleauth2/auth.php
instead
294 $user = authenticate_user_login($username, null);
-> $user = get_complete_user_data('username', $username, $CFG->mnet_localhost_id);
profit!