OAuth 2 Google service: Difference between revisions

From MoodleDocs
mNo edit summary
(See also forum discussion links)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{OAuth2}}
{{OAuth2}}
=== Setup Project In Google ===
==Features requiring the OAuth 2 Google service==


To setup an OAuth 2 client with Google, first we need to login to the [https://console.developers.google.com/ Google Developers Console] and create a new project.
You will need to set up an OAuth 2 Google service in order to use the following features:


Create a new project using the menu at the top of the page.
* [[Google Drive repository]]
* [[OAuth 2 authentication]] for enabling users to log in to Moodle with their Google account
* [[Google Drive converter]] for converting assignment submission files to PDF for teachers to annotate


[[File:google-1-create-new.png|none|frame|Create new project]]
==OAuth 2 Google service setup==


Call the new project whatever you like, this name is not shown to users when they are asked to authorise this application.
To set up an OAuth 2 client with Google, log in to the [https://console.developers.google.com/ Google Developers Console] and click the arrow by 'Select a project'.
 
[[File:SelectAProject.png]]
 
Click 'Create a new project'
 
[[File:New project.png]]
 
Give it a name. The name is not visible to anyone so you can choose any name you like.


[[File:google-2-create-new-modal.png|none|frame|Name the project]]
[[File:google-2-create-new-modal.png|none|frame|Name the project]]


Select "credentials" from the menu on the left.
Click Credentials from the menu on the left.


[[File:google-3-credentials.png|none|frame|Switch to credentials page]]
[[File:google-3-credentials.png|none|frame|Switch to credentials page]]
Line 18: Line 28:
Setup the consent screen for your application. This is where you provide the public information that is shown to users when they are asked to authorise your application. Setting a product name is the minimum information that is required, but the more information you provide here - the more confidence users will have when granting this authorisation.
Setup the consent screen for your application. This is where you provide the public information that is shown to users when they are asked to authorise your application. Setting a product name is the minimum information that is required, but the more information you provide here - the more confidence users will have when granting this authorisation.


[[File:google-4-consent.png|none|frame|Setup consent screen]]
[[File:app information.png|none|frame|Setup consent screen]]


Now you can create some client credentials. Switch to the credentials tab and create a new OAuth client ID.  
Now you can create some client credentials. Click Credentials from the menu on the left again then click "+ Create credentials" and select OAuth client ID.


[[File:google-5-oauth-credentials.png|none|frame|Create an OAuth Client ID]]
[[File:google-5-oauth-credentials.png|none|frame|Create an OAuth Client ID]]


Setup the credentials for a Web Application. The most important setting here is to set the callback URL. This must be set to "your moodle site url + /admin/oauth2callback.php". If your moodle site was accessible at <nowiki>https://lemon.edu/</nowiki> then this callback URL should be set to <nowiki>https://lemon.edu/admin/oauth2callback.php</nowiki>.
Select Web application as Application type and click to add an authorised redirect URI. This must be set to "your moodle site url + /admin/oauth2callback.php". If your Moodle site was accessible at <nowiki>https://lemon.edu/</nowiki> then this callback URL should be set to <nowiki>https://lemon.edu/admin/oauth2callback.php</nowiki>. Enter the URL then click Create.


[[File:google-6-web-application-credentials.png|none|frame|Set the callback URL]]
[[File:google-6-web-application-credentials.png|none|frame|Set the callback URL]]
Line 33: Line 43:


Finally we have to enable the Drive API (if we want to use the google drive repository or file converter plugins).
Finally we have to enable the Drive API (if we want to use the google drive repository or file converter plugins).
Click Library from the menu on the left.


[[File:google-8-library.png|none|frame|View the Library tab]]
[[File:google-8-library.png|none|frame|View the Library tab]]


[[File:google-9-select-drive.png|none|frame|Select Drive API]]
Search for drive and select Google Drive API. Click the Enable button.


[[File:google-10-enable-drive.png|none|frame|Enable the API]]
[[File:google-10-enable-drive.png|none|frame|Enable the API]]


==App verification==
NOTE: If you are just using this for document conversion you will not need to verify (as it only uses one account). You will, however, need to verify your ownership of your domain (see [https://support.google.com/webmasters/answer/35179 Verify your site ownership - Search Console Help].)
The Google Drive repository and Google Drive converter also require the app to be verified by completing the OAuth Developer Verification Form. The list of scopes that Moodle requires are: <code><nowiki>openid profile email https://www.googleapis.com/auth/drive</nowiki></code>.
==See also==
Moodle in English forum discussions:
* [https://moodle.org/mod/forum/discuss.php?d=356871 Google Drive Repository and Moodle 3.3.1]
* [https://moodle.org/mod/forum/discuss.php?d=416645 Setting up Oauth2 service Google]


[[es:Servicio OAuth 2 Google]]
[[es:Servicio OAuth 2 Google]]
[[de:OAuth2 Google Service]]
[[de:OAuth2 Google Service]]

Latest revision as of 16:17, 18 February 2021

Features requiring the OAuth 2 Google service

You will need to set up an OAuth 2 Google service in order to use the following features:

OAuth 2 Google service setup

To set up an OAuth 2 client with Google, log in to the Google Developers Console and click the arrow by 'Select a project'.

SelectAProject.png

Click 'Create a new project'

New project.png

Give it a name. The name is not visible to anyone so you can choose any name you like.

Name the project

Click Credentials from the menu on the left.

Switch to credentials page

Setup the consent screen for your application. This is where you provide the public information that is shown to users when they are asked to authorise your application. Setting a product name is the minimum information that is required, but the more information you provide here - the more confidence users will have when granting this authorisation.

Setup consent screen

Now you can create some client credentials. Click Credentials from the menu on the left again then click "+ Create credentials" and select OAuth client ID.

Create an OAuth Client ID

Select Web application as Application type and click to add an authorised redirect URI. This must be set to "your moodle site url + /admin/oauth2callback.php". If your Moodle site was accessible at https://lemon.edu/ then this callback URL should be set to https://lemon.edu/admin/oauth2callback.php. Enter the URL then click Create.

Set the callback URL

When you have saved the information on this page, Google will give you the client ID and client secret that you need to enter into Moodle.

Got my secrets!

Finally we have to enable the Drive API (if we want to use the google drive repository or file converter plugins).

Click Library from the menu on the left.

View the Library tab

Search for drive and select Google Drive API. Click the Enable button.

Enable the API

App verification

NOTE: If you are just using this for document conversion you will not need to verify (as it only uses one account). You will, however, need to verify your ownership of your domain (see Verify your site ownership - Search Console Help.)

The Google Drive repository and Google Drive converter also require the app to be verified by completing the OAuth Developer Verification Form. The list of scopes that Moodle requires are: openid profile email https://www.googleapis.com/auth/drive.

See also

Moodle in English forum discussions: