Skip to content

Latest commit

 

History

History

google

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Example for accessing Google APIs with OAuth 2.0

Prerequisites

Before running these examples, you will need the following:

  • See instructions in oauth_examples README
  • A Google Developer Account, you can sign up for one at https://developer.google.com/.
  • A Google Developer project with an OAuth 2.0 Client ID, configured for a Web application. This is done from the Google Developer Console and you can find instructions here.

Now you need to gather the following information from the Google Developer Console that belongs to your front-end application:

  • Client ID and Client Secret - The client ID and secret of the Web application that you created earlier. This can be found on the right hand side of the screen when you are in the " Client ID for Web application " view . This identifies the application that tokens will be minted for.

Copy the client_config.py.dist to client_config.py and fill in the information you gathered as well as edit the other fields to suit your deployment scenario

google_client_id = 'xxx-xxx.apps.googleusercontent.com'
google_client_secret ='xxx'

authorize_url = 'https://accounts.google.com/o/oauth2/v2/auth'

token_url = 'https://www.googleapis.com/oauth2/v4/token'


base_url = 'http://localhost:5000/'

user_info_url = 'https://www.googleapis.com/oauth2/v3/userinfo' 

run the sample by typing:

python3 google_client.py

Access the application by going to : http://localhost:5000/