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

Authentication ::: auth_googleoauth2
Maintained by Sergio Rabellino
Part of set OAuth2.
Sign-in with an Oauth2 provider. The first time you sign-in, a new account is created.
Latest release:
628 sites
119 downloads
272 fans
Current versions available: 3

Plugin end of life starting from Moodle 3.3

starting from Moodle 3.3, Oauth2 should be implemented in Moodle core. It will require you to upgrade to Moodle 3.3 and switch to the Oauth2 core authentication (and probably do some migration), but it is a great news as authentication is a really sensible matter and having Oauth2 plugins in core will guarantee their maintenance. So starting from Moodle 3.3 I highly recommend to use the new Oauth2 core plugins ((https://docs.moodle.org/dev/Better_Office_Integrations_3.3#Core_API_for_managing_Authorized_OAuth_Applications) ) . Missing core providers will likely be implemented by someone and published in the Moodle.org plugin repository. There will probably be a new Oauth2 category in the Moodle plugin repository. Wait and see...

I will try to mantain this plugin until Moodle 3.1 (LTS) runs out of security upport  (13 May 2019).


Warning for Facebook users 

The plugin stopped working the 27th March 2017 as Facebook closed the API 2.2. The last versions of this plugin have been updated to support Facebook 2.8 API. As usual carefully test before upgrading a third party plugin if your Moodle site is important to you (especially as it is an authentication plugin)


Installation

  1. add the plugin into /auth/googleoauth2/
  2. in the Moodle administration, enable the plugin (Admin block > Plugins > Authentication)
  3. in the plugin admin page, follow the displayed instructions.

I also created a free mini-course on how to install a Moodle plugin using Oauth2 plugin as example.


Documentation and support

You can search in all existing issues on Github. Go to the issues page, next to the filter button there is a search field. Remove the default content, type your keywords and press enter.

There is a FAQ too.

Alternative plugins

There are many alternatives to this plugin, if you have any trouble with this plugin it may be a good idea to try them:

Screenshots

Screenshot #0

Contributors

Sergio Rabellino (Lead maintainer)
Jérôme Mouneyrac: Original author and previous maintainer
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Alex Ivanov
    Sat, 20 Oct 2012, 12:50 AM
    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!
  • Bodo Hoenen
    Tue, 19 Feb 2013, 5:12 AM
    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?
  • Cinthia Reyes
    Thu, 14 Mar 2013, 12:39 PM
    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?
  • Jérôme Mouneyrac
    Wed, 17 Apr 2013, 4:03 PM
    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.
  • Jérôme Mouneyrac
    Wed, 17 Apr 2013, 4:23 PM
    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)
  • Mandi Nanga
    Wed, 5 June 2013, 5:54 PM
    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.
  • Johan Nyman
    Mon, 10 June 2013, 11:12 PM
    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';
  • dante casalena
    Fri, 21 June 2013, 1:20 AM
    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!!!!
  • Seth Mengal
    Fri, 21 June 2013, 3:59 PM
    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
  • Graham Bowman
    Sat, 22 June 2013, 4:54 PM
    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
  • Graham Bowman
    Sat, 22 June 2013, 6:05 PM
    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
  • N R
    Wed, 26 June 2013, 11:36 PM
    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.
  • N R
    Thu, 27 June 2013, 10:37 PM
    You shouldn't use this plugin, it's too much unsafe.
  • Jérôme Mouneyrac
    Mon, 8 July 2013, 11:03 AM
    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.
  • William Machin
    Mon, 22 July 2013, 10:12 PM
    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?
Please login to post comments