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:
716 sites
114 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

  • Toshendra Sharma
    Mon, 16 Sept 2013, 1:45 AM
    Getting 500 Internal Server Error while returning back from Facebook, Git & Gmail.

    Ref: www.wegversity.com/courseware
  • Toshendra Sharma
    Mon, 16 Sept 2013, 1:47 AM
    Saying something Dangerously writable: [/home3/tos*****/public_html/wegversity/courseware/auth/googleoauth2/facebook_redirect.php]
    FIXED

    What could be wrong?
  • Vivek mahadevan
    Mon, 16 Sept 2013, 10:18 AM
    Hi Jeremy,

    I'm just looking around to try out the oauth authentication method, to possibly try and extend it. Is there any way that I could get this working on local?
  • Jérôme Mouneyrac
    Mon, 16 Sept 2013, 6:06 PM
    Hi Toshendra and Vivek,
    about the 500 Internal error, please write an issue in the github tracker issue. We can follow up from there. Don't forget to provide the exact step to reproduce and to mention your environment.

    About the plugin not working in local, you can use service like http://progrium.com/localtunnel/ to give online access to a local server.
  • Regul Red
    Tue, 24 Sept 2013, 10:01 PM
    This plugin not work in my Moodle 2.5.2+

    I research problem and find, what there is error in /auth/googleauth2/auth.php

    In line 359 used authenticate_user_login function, that dont work with empty second parameter (password).

    Replace
    $user = authenticate_user_login($username, null);
    -->
    $user = get_complete_user_data('username', $username, $CFG->mnet_localhost_id);
    or $DB-> get_record function
    solve this problem.
  • Jérôme Mouneyrac
    Tue, 24 Sept 2013, 10:29 PM
  • Jérôme Mouneyrac
    Tue, 24 Sept 2013, 10:56 PM
    I tried with the last 2.5 stable version, it works fine for me.
  • Jérôme Mouneyrac
    Tue, 24 Sept 2013, 11:04 PM
    Just a reminder, if possible do not report issues here but on the github: https://github.com/mouneyrac/moodle-auth_googleoauth2/issues?state=open

    Also when reporting issue don't hesitate to turn debug mode ON in moodle, and give the full error message. Also mention your environment it can help to resolve an issue.

    On github there is also a wiki/faq: https://github.com/mouneyrac/moodle-auth_googleoauth2/wiki

    Thanks smile
  • Darrel Tenter
    Thu, 21 Nov 2013, 8:41 AM
    I'll report isses to github if needed, but I'm not sure if these are bug issues, or configuration issues on my end.

    I'm running Moodle 2.5.3+ (Build: 20131115)

    I've just installed the plugin. I am able to login with Facebook and Google.

    For LinkedIn I'm getting "Error writing to database". Here's the anonymized debug info:
    Debug info: Column 'country' cannot be null
    UPDATE mdl_user SET email = ?,firstname = ?,lastname = ?,country = ?,city = ? WHERE id=?
    [array (
    0 => 'linkedinuser@domain.com',
    1 => 'First',
    2 => 'Last',
    3 => NULL,
    4 => NULL,
    5 => '17',
    )]
    Error code: dmlwriteexception
    Stack trace:
    line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown
    line 1195 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
    line 1227 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->update_record_raw()
    line 371 of /auth/googleoauth2/auth.php: call to mysqli_native_moodle_database->update_record()
    line 88 of /login/index.php: call to auth_plugin_googleoauth2->loginpage_hook()
    Output buffer: Notice: Undefined property: stdClass::$country in /var/www/vhosts/mysite.com/httpdocs/auth/googleoauth2/auth.php on line 326 Notice: Trying to get property of non-object in /var/www/vhosts/mysite.com/httpdocs/auth/googleoauth2/auth.php on line 326 Notice: Undefined property: stdClass::$name in /var/www/vhosts/mysite.com/httpdocs/auth/googleoauth2/auth.php on line 327

    My LinkedIn First, Last, and email address were in the debug info.
    Any advice would be appreciated.

    Thanks,
    Darrel
  • Balakrishna Thumma
    Wed, 8 Jan 2014, 3:30 PM
    Hi I am installed auth googleoauth2 plugin, but facing the problem following error is:
    The authentication provider sent us a communication error. Please try to sign-in again.
  • Ken Task
    Sun, 19 Jan 2014, 11:48 PM
    Great plugin! Thanks. Works for individual G accounts, but will it work with schools that have 'gone Google' ... ie, have a Google domain for the school? Is there some admin setting where that could be added/changed in the Moodle Admin UI? Also, if one logs out of Moodle, does it also logout of Google?
    Again ... thanks for your work. 'spirit of sharing', Ken
  • Graham Bowman
    Mon, 20 Jan 2014, 2:57 AM
    @Ken Task, it works exactly the same for Google Apps for Education/Business accounts. We combined our system with Moodle's ability to restrict the email address to specified domains. One tip is to add hd=domain.com as a parameter in the google login URL. This saves typing in the whole email address when logging in. See an example at http://ssa-vle.org.uk
    The domain specific login page is due to be depreciated soon, I don't know if this method will be affected.
  • Ken Task
    Tue, 21 Jan 2014, 2:59 AM
    @Graham. Thanks. Pardon my denseness, but what file do I edit to add the hd=domain.com parameter to the google login URL? Thanks, in advance, Ken
  • Graham Bowman
    Wed, 22 Jan 2014, 7:45 AM
    In the instructions I think it says to edit /login/index.php
    There is now a theme which shows how to add the buttons to an existing login page. In that theme it would be /layout/login.php where you add had=domain.com
    Let me know if you get stuck.
  • Tadthai Praichan
    Sun, 23 Feb 2014, 6:44 PM
    I try Oauth2 with Moodle 2.6
    facebook login not work
    google+ is very well
    how can i solve facebook login ?
Please login to post comments