avinashkranjan / Amazing-Python-Scripts

🚀 Curated collection of Amazing Python scripts from Basics to Advance with automation task scripts.
https://amazing-python-scripts.avinashranjan.com
MIT License
2.68k stars 1.05k forks source link

[Script]: Google-Meet-Scheduler #3095

Closed vishnu-v-vardhan closed 9 months ago

vishnu-v-vardhan commented 9 months ago

Aim

To simplify the OAuth authentication and terminate reliance on pickle module to make the code more redundant while retaining the core functionality.

Details

3094

The latest code features the following code to handle authentication: `def _auth(): creds = None if os.path.exists("token.json"): creds = Credentials.from_authorized_user_file("token.json", SCOPES)

If there are no (valid) credentials available, let the user log in.

    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                "credentials.json", SCOPES
            )
            creds = flow.run_local_server(port=0)
            # Save the credentials for the next run
            with open("token.json", "w") as token:
                token.write(creds.to_json())

    service = build("calendar", "v3", credentials=creds)
    return service`

A global variable 'SCOPES' is used to define "https://www.googleapis.com/auth/calendar".

Record

github-actions[bot] commented 9 months ago

To reduce notifications, issues are locked. Your issue will be unlocked when we add the label gssoc23. If you're participating in GSSoC'23, please add the gssoc23 label to your issue.