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.
Comments
Comments are no longer open for new posts. Existing comments remain available to read.
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?
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
It seems it refreshes back to Login after loggin in? Could u see whats up? Its 2.5
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!!!!
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';
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.
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
'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?
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!