def auth_as_user()

in gcal.py [0:0]


def auth_as_user():
    """Prompt the user to authorize access to their calendars via a web browser and returns
    credentials on success. If this is called a second time, the user will not be prompted because a
    cached version will be used.

    To call this API locally, you must get a PATH_GCLOUD_PROJECT_SECRETS: see the top-of-file
    comment.
    """
    creds = _fetch_cached_user_credentials()
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        elif IN_AUTOMATION:
            raise CredentialException(('Credentials unavailable for refresh. Credentials must be '
                                       'refetched manually and updated in secrets.'))
        else:
            flow = InstalledAppFlow.from_client_secrets_file(PATH_GCLOUD_PROJECT_SECRETS, SCOPES)
            creds = flow.run_local_server(port=0)

        if not IN_AUTOMATION:  # Don't save secrets to disk.
            with open(PATH_CACHED_USER_SECRETS, "w") as token:
                token.write(creds.to_json())
    return creds