Gets OAuth2 access token from Google/YouTube automatically, using requests_oauthlib
I developed this when I found that I needed to get data from Google and YouTube API automatically, but there was always the human entry for OAuth2 flow. This library takes care of that with your selected webdriver
pip3 install --user oauth2_google_login
First, setup Chrome Webdriver so that it is in PATH, which can be done in terminal
export PATH=$PATH:/home/username/Downloads/chromedriver
Then in Python, run
from oauth2_google_login import get_access_token
auth = get_access_token(
email = "user@email.com",
password = "password",
client_id="1234567",
client_secret="a1b2c3d4e5",
scope = ['https://www.googleapis.com/auth/yt-analytics.readonly', "https://www.googleapis.com/auth/youtube.readonly"]
)
auth.access_token # Facebook access token
from oauth2_google_login import get_access_token
from selenium import webdriver
driver = webdriver.Chrome("/home/username/Downloads/chromedriver")
auth = get_access_token(
email = "user@email.com",
password = "password",
client_id="1234567",
client_secret="a1b2c3d4e5",
scope = ['https://www.googleapis.com/auth/yt-analytics.readonly', "https://www.googleapis.com/auth/youtube.readonly"],
driver = driver
)
auth.access_token # Facebook access token
1.0.x
- First Publish