Skip to content

Instantly share code, notes, and snippets.

@dlazesz
dlazesz / google_oauth2_python3.py
Created June 8, 2022 00:04
Google API OAuth 2.0 Authorization Sample in Python 3 (with requests-oauthlib)
View google_oauth2_python3.py
from requests_oauthlib import OAuth2Session
# Credentials you get from registering a new application
client_id = "<the id you get from google>"
client_secret = "<the secret you get from google>"
# OAuth endpoints given in the Google API documentation
authorization_base_url = "https://accounts.google.com/o/oauth2/v2/auth"
token_url = "https://www.googleapis.com/oauth2/v4/token"
scope = [