Configuring Google OAuth

Introduction

This article describes how to customize Geo2Tag for using Google OAuth. The setting takes place in two stages. At first the corresponding record should be created at https://console.developers.google.com/, then parameters of record should be added to config.ini.

Setting in Google Developer Console

  1. At https://console.developers.google.com/start press the button “Enable Google APIs for use in your apps”.


2. In the appeared window enter the name of project, click the check box and press  Create. 

3. Next you need press the button“Enable Google APIs for use in your apps” again, after that a window with dropbox of projects will appear.

4. Select the created project and press Continue.

5. On the next page in the left menu press “API & auth /Credentials“.

6. Then you need to press the button  Create new Client ID“.

7. In the next window you should click radio button “Web application” and press “Configure consent screen“.

8. Next you need to fill the field “Product name” and press the button “Save“.

9. In the next window you should enter following data: 

  • Into the field “Authorized JavaScript origins” the name of host where Geo2Tag is delivered should be inserted.
  • Into the field “Authorized redirect URIs” you should specify the link:  https://<domain name of the host>/<prefix (by default instance)>/login/google/authorized. If you don’t know your prefix you can find out its value in the file var/www/geomongo/config.ini, parameter instance_prefix.

As the result you should get approximately like this window.

 

Settings in config.ini

For futher setting you need to open the file  /var/www/geomongo/config.ini with any text editor and edit (add if the section didn’t exist earlier) the section “Google_OAuth” by the next way (on the basis of data from the last screenshot in previous section):

[Google_OAuth]
GOOGLE_CLIENT_ID=<field Client ID>
GOOGLE_CLIENT_SECRET=<field Client secret>
GOOGLE_REDIRECT_URL=<link from Authorized redirect URIs>

Testing

For testing you need to:

  1. follow the link /<Prefix>/login,
  2. press the button “Sign in with Google”,
  3. enter login and password,
  4. accept usage API (the next image),
  5. after that you will be redirected to the page “/instance/login/google/authorized?” where “Success” will be displayed.

Links

  1. https://developers.google.com/identity/protocols/OAuth2
  2. https://developers.google.com/console/help/new/?hl=en_US#generatingoauth2
ShareShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VKEmail this to someone