Service accounts represent non-human users. They’re intended for scenarios where a workload, such as a custom application, needs to access resources or perform actions without end-user involvement. Service accounts differ from normal user accounts in multiple ways:Please move to “APIs & Services” > “Service Accounts”. And then please click “CREATE SERVICE ACCOUNT”. Please input service account name and click “CREATE” button. Other things are optional. So, I’ll skip inputting them because this time is just test. Please click “CONTINUE” and “DONE” buttons.
– They don’t have a password and can’t be used for browser-based sign-in.
– They’re created and managed as a resource that belongs to a Google Cloud project. In contrast, users are managed in a Cloud Identity or Google Workspace account.
– They’re specific to Google Cloud. In contrast, the users managed in Cloud Identity or Google Workspace work across a multitude of Google products and services. This guide presents best practices for managing, using, and securing service accounts.Best practices for using and managing service accounts
https://cloud.google.com/iam/docs/best-practices-for-using-and-managing-service-accounts
Here is Python script code. You can see calendar_id from Google Calendar’s “Settings and sharing” page (See “Integrate calendar”). And credentials.json is Service Account key.pip install google-api-python-client google-auth
If you run the script, you can see your events like following.import datetime, re import googleapiclient.discovery import google.auth # Preparation for Google API SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'] calendar_id = 'xxxxx' gapi_creds = google.auth.load_credentials_from_file('credentials.json', SCOPES)[0] service = googleapiclient.discovery.build('calendar', 'v3', credentials=gapi_creds) # Get events from Google Calendar API now = datetime.datetime.utcnow().isoformat() + 'Z' events_result = service.events().list( calendarId=calendar_id, timeMin=now, maxResults=5, singleEvents=True, orderBy='startTime').execute() # Pick up only start time, end time and summary info events = events_result.get('items', []) formatted_events = [(event['start'].get('dateTime', event['start'].get('date')), # start time or day event['end'].get('dateTime', event['end'].get('date')), # end time or day event['summary']) for event in events] # Generate output text response = '[Closest 5 events]\n' for event in formatted_events: if re.match(r'^\d{4}-\d{2}-\d{2}$', event[0]): start_date = '{0:%Y-%m-%d}'.format(datetime.datetime.strptime(event[1], '%Y-%m-%d')) response += '{0} All Day\n{1}\n\n'.format(start_date, event[2]) # For all day events else: start_time = '{0:%Y-%m-%d %H:%M}'.format(datetime.datetime.strptime(event[0], '%Y-%m-%dT%H:%M:%S+00:00')) end_time = '{0:%H:%M}'.format(datetime.datetime.strptime(event[1], '%Y-%m-%dT%H:%M:%S+00:00')) response += '{0} ~ {1}\n{2}\n\n'.format(start_time, end_time, event[2]) response = response.rstrip('\n') print(response)
That’s it.$ python get_events.py [Closest 5 events] 2021-05-30 19:00 ~ 20:00 Test Event 1 2021-05-30 20:45 ~ 21:00 Test Event 2 2021-05-30 21:30 ~ 22:00 Test Event 3 2021-05-30 23:15 ~ 01:00 Test Event 4 2021-06-01 All Day Test Event 5
Streamlit is a …
I bought M5Stac…