ImagiGen_v2 / google_auth.py
Tejasva-Maurya's picture
Update google_auth.py
e5d147f verified
raw
history blame contribute delete
740 Bytes
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
import os
import json
# Define OAuth 2.0 scopes
SCOPES = os.getenv('Google_scopes')
config = os.getenv('Google_secret')
config = json.loads(config)
def auth():
api_service_name = "drive"
api_version = "v3"
flow = InstalledAppFlow.from_client_config(config, scopes=SCOPES)
credentials = flow.run_local_server(port=0)
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