Select Moodle version:

Authentication: Google / Facebook / Github / Linkedin / Windows authentication

Sign-in with your Google / Facebook / Github / Linkedin / Windows Live account. The first time you sign-in, a new account is created.
Maintained by: Picture of Jérôme Mouneyrac Jérôme Mouneyrac
for Moodle
2.1, 2.2, 2.3, 2.4, 2.5


This plugin is part of set OAuth2. Plugins from the set work the best when installed together.

This plugin adds the "Sign-in with Google / Facebook / Github / Linkedin / Windows Live" buttons on the login page. The first time the user login with a social account,  a new Moodle account is created.


  1. add the plugin into /auth/googleoauth2/
  2. in the Moodle administration, enable the plugin (Admin block > Plugins > Authentication)
  3. in the plugin settings, follow the displayed instructions.
  4. Add the following code to your login page :

<?php require_once($CFG->dirroot . '/auth/googleoauth2/lib.php'); auth_googleoauth2_display_buttons(); ?>

Most of you will need to copy the code at the bottom of login/index_form.html. Some custom themes have their own login page. In this case you should find the login layout page indicated in the theme config.php file. Often the file location is something like /theme/YOURTHEME/layout/login.php.

More information

More information on the official web site.







Picture of Jérôme Mouneyrac
Jérôme Mouneyrac (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Jérôme Mouneyrac
    Tue, Sep 24, 2013, 11:04 PM
    Just a reminder, if possible do not report issues here but on the github:

    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:

    Thanks smile
  • Picture of Darrel Tenter
    Thu, Nov 21, 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 => '',
    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/ on line 326 Notice: Trying to get property of non-object in /var/www/vhosts/ on line 326 Notice: Undefined property: stdClass::$name in /var/www/vhosts/ on line 327

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

  • Picture of Balakrishna Thumma
    Wed, Jan 8, 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.
  • Picture of Ken Task
    Sun, Jan 19, 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
  • Picture of Graham Bowman
    Mon, Jan 20, 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 as a parameter in the google login URL. This saves typing in the whole email address when logging in. See an example at
    The domain specific login page is due to be depreciated soon, I don't know if this method will be affected.
  • Picture of Ken Task
    Tue, Jan 21, 2014, 2:59 AM
    @Graham. Thanks. Pardon my denseness, but what file do I edit to add the parameter to the google login URL? Thanks, in advance, Ken
  • Picture of Graham Bowman
    Wed, Jan 22, 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
    Let me know if you get stuck.
  • Picture of Tadthai Praichan
    Sun, Feb 23, 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 ?
  • Picture of Chetan Sharma
    Tue, Feb 25, 2014, 11:23 PM
    The FB Connect is working fine. All i want now is how can the FB profile pic automatically becomes the user's profile pic in Moodle.
    Also, how can we know that how many users have logged into our moodle site with thier FB. Where can i find details about them???
  • Picture of Tadthai Praichan
    Wed, Feb 26, 2014, 6:33 AM
    Hi Chetan
    when I sign in with facebook and windows Live
    webpage back to Log in again ..I don't why ?
  • Picture of Tadthai Praichan
    Sun, Mar 2, 2014, 6:28 PM
    please visit and help for check
    when login with facebook and windows live can not access siad webpage i use moodle 2.6
    thanks in advance
  • Picture of Mahesh Patil
    Tue, Mar 11, 2014, 1:46 PM
    I installed this plugin moodle2.3.1+
    I got the following error ,after facebook login which redirect to my site."Error writing to database" ...
  • Picture of Mahesh Patil
    Tue, Mar 11, 2014, 1:47 PM
    I installed this plugin moodle2.3.1+
    I got the following error ,after facebook login which redirect to my site."Error writing to database" ...
  • Picture of Ken Task
    Fri, Apr 4, 2014, 3:43 AM
    @Graham Bowman - ok, am stuck adding the parameter to the google login URL.
    Directions say to add a line to index_form.html but what I'm seeing doesn't look like a link that goes to Google. Thanks, in advance, for any assistance.
  • Picture of Graham Bowman
    Fri, Apr 4, 2014, 5:34 AM
    index_form.php is the code for the username/password for a standard moodle login. Follow the instructions to add a login with Google button. Then in auth/googleoauth2/lib.php find href=" and add
    between href= and https://

    If that doesn't make sense send me a PM. It's not as good as the hd= method but that doesn't work any more, this method will add the to their Google login screen so they just add their username.
1 2 3 4 5 6
Please login to post comments