Note: You are currently viewing documentation for Moodle 3.4. Up-to-date documentation for the latest stable version of Moodle is likely available here: Google OAuth 2.0 setup.

Google OAuth 2.0 setup: Difference between revisions

From MoodleDocs
(updating Registering with Google instructions and linking to Google Dev doc rather than providing screenshots, since the UI is changed so often)
Line 4: Line 4:
==Registering with Google==
==Registering with Google==


Each Moodle site  needs to be registered with Google in order to use the Google Drive, Docs or Picasa plugins. As part of the registration process, you will need to enter a URL (something like <nowiki>http://yourmoodlesite.org/admin/oauth2callback.php</nowiki>) which is provided on all Google Drive, Docs and Picasa plugins configuration pages in Moodle e.g. ''Administration > Site administration > Plugins > Repositories > Google Drive''.
Each Moodle site  needs to be registered with Google i.e. have a Google Developers Console project in order to use the Google Drive, Docs or Picasa plugins. As part of the registration process, you will need to enter an authorized redirect URI (something like <nowiki>http://yourmoodlesite.org/admin/oauth2callback.php</nowiki>) which is provided on all Google Drive, Docs and Picasa plugins configuration pages in Moodle, such as ''Site administration > Plugins > Repositories > Google Drive''.


1) Visit the [https://console.developers.google.com/ Google Developers Console] (previously, the [https://cloud.google.com/console/project#access Google Cloud APIs Console], or the [https://code.google.com/apis/console#access Google APIs Console]) and sign into your google account.
To create a Google Developers Console project:
2) If it is your first time you will be asked to create a project:
[[File:01g.png|center|thumb|400px]]
3) Give your project a name
[[File:02g.png|thumb|center|400px]]
4) If not already enabled, the Google Drive API needs enabling. Click "Enable an API":
[[File:03g.png|thumb|center|400px]]
5) Change Drive API to "On":
[[File:04g.png|thumb|center|400px]]
6) From the left menu, click "Credentials":
[[File:05g.png|thumb|center|400px]]
7) In the OAuth block, click "Create  new client ID"
[[File:06g.png|thumb|center|400px]]
8) Leave the Javascript redirect blank and add the redirect URL you have from ''Administration > Site administration > Plugins > Repositories > Google Drive'' and then click "Create client ID".You can also enter your branding details here.
[[File:08g.png|thumb|center|400px]]
9) Go to the Consent Screen and enter an Email address and a Product name:
[[File:google-oa2-consent-screen.png|thumb|center|400px]]
10) On your set up page enter the ID and secret you got at step 8:
[[File:09g.png|thumb|center|400px]]


# Go to the [https://console.developers.google.com/ Google Developers Console] and sign in to your Google account.
# Follow the instructions provided in the Google Developers doc [https://developers.google.com/identity/sign-in/web/devconsole-project Creating a Google Developers Console project and client ID].
# When creating a new Client ID
## In the Application type section of the dialog, select Web application.
## Leave the Authorized JavaScript origins field empty and in the Authorized redirect URI field, enter the URL from your site.


Tip: If you have more than one Moodle site to register with Google, you can add an authorized redirect URI for each site in step 8. The same name and logo would then be displayed on the authorisation screen for each Moodle site.
Tip: If you have more than one Moodle site to register with Google, you can add an authorized redirect URI for each site. The same name and logo would then be displayed on the authorisation screen for each Moodle site.


==Configuring the Google Drive and Picasa repositories==
==Configuring the Google Drive and Picasa repositories==
Line 42: Line 29:
# Configure each portfolio by entering the client ID and secret
# Configure each portfolio by entering the client ID and secret
# Save changes
# Save changes


Once configured, Google will present Moodle users with a nice authorisation screen with your Moodle site name and logo for your users to authorise.
Once configured, Google will present Moodle users with a nice authorisation screen with your Moodle site name and logo for your users to authorise.

Revision as of 14:28, 3 February 2016

Note: This page contains information for site administrators only.

Registering with Google

Each Moodle site needs to be registered with Google i.e. have a Google Developers Console project in order to use the Google Drive, Docs or Picasa plugins. As part of the registration process, you will need to enter an authorized redirect URI (something like http://yourmoodlesite.org/admin/oauth2callback.php) which is provided on all Google Drive, Docs and Picasa plugins configuration pages in Moodle, such as Site administration > Plugins > Repositories > Google Drive.

To create a Google Developers Console project:

  1. Go to the Google Developers Console and sign in to your Google account.
  2. Follow the instructions provided in the Google Developers doc Creating a Google Developers Console project and client ID.
  3. When creating a new Client ID
    1. In the Application type section of the dialog, select Web application.
    2. Leave the Authorized JavaScript origins field empty and in the Authorized redirect URI field, enter the URL from your site.

Tip: If you have more than one Moodle site to register with Google, you can add an authorized redirect URI for each site. The same name and logo would then be displayed on the authorisation screen for each Moodle site.

Configuring the Google Drive and Picasa repositories

  1. Go to Administration > Site administration > Plugins > Repositories > Manage Repositories
  2. Activate the Google Drive and/or Picasa repositories by selecting 'Enable and visible' in the dropdown menu
  3. Configure each repository by entering the client ID and secret. Make sure you don't include any white space in the text boxes!
  4. Save changes

Configuring the Google Drive and Picasa portfolios

  1. Go to Administration > Site administration > Plugins > Portfolios > Manage Portfolios
  2. Activate the Google Drive and/or Picasa portfolios by selecting 'Enable and visible' in the dropdown menu
  3. Configure each portfolio by entering the client ID and secret
  4. Save changes

Once configured, Google will present Moodle users with a nice authorisation screen with your Moodle site name and logo for your users to authorise.