Skip to content

Instantly share code, notes, and snippets.

@lowweihong
Last active August 14, 2019 07:09
Show Gist options
  • Save lowweihong/c463fffaee6b557a0df9467c7300c54c to your computer and use it in GitHub Desktop.
Save lowweihong/c463fffaee6b557a0df9467c7300c54c to your computer and use it in GitHub Desktop.
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import requests
import pandas as pd
from datetime import datetime, timedelta
from bs4 import BeautifulSoup
import os
gauth = GoogleAuth()
# Try to load saved client credentials
gauth.LoadCredentialsFile("mycreds.txt")
if gauth.credentials is None:
# Authenticate if they're not there
gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
# Refresh them if expired
gauth.Refresh()
else:
# Initialize the saved creds
gauth.Authorize()
# Save the current credentials to a file
gauth.SaveCredentialsFile("mycreds.txt")
# Authentication
drive = GoogleDrive(gauth)
# Input destination folder id which you want to upload to.
current_google_folder_id = 'xxxxx'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment