from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow

# Define the scopes for the Google Sheets API
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']

# Set up the OAuth2 flow to get the user's authorization
flow = InstalledAppFlow.from_client_secrets_file(
    'web_credentials.json',
    scopes=['https://www.googleapis.com/auth/spreadsheets.readonly']
)

flow.redirect_uri = 'http://www.connectingpersonality.com:443'

creds = flow.run_local_server(port=443)

# Build the Google Sheets API client using the credentials
service = build('sheets', 'v4', credentials=creds)