ImagiGen_v2 / google_auth.py
Tejasva-Maurya's picture
Create google_auth.py
e6eb3cf verified
raw
history blame
697 Bytes
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
# Define OAuth 2.0 scopes
SCOPES = {os.getenv('Google_scopes')}
config = {os.getenv('Google_Secret')}
def auth():
api_service_name = "drive"
api_version = "v3"
flow = InstalledAppFlow.from_client_config(config, scopes=SCOPES)
credentials = flow.run_local_server(port=5000)
drive = build(api_service_name, api_version, credentials=credentials)
drive.about().get(fields="user").execute()
# Use the Drive API client to fetch user information
user_info = drive.about().get(fields="user").execute()
return user_info