Refer Google OAuth Documentation
- Creates an instance of google_auth_oauthlib.flow.Flow by reading the client secrets from a specified file.
- Sets the redirect URI to a specified URL, which must match one of the authorized redirect URIs for the OAuth 2.0 client.
- Generates an authorization URL and a state, which is used to initiate the OAuth 2.0 authorization grant flow.
- Stores the state in the session so that it can be verified in the authorization server response.
- Returns a Response object with the authorization URL as its content.
- Starts by retrieving the state from the session and creating an OAuth2 flow object with the specified client secrets file and scopes.
- Exchanges the authorization code in the authorization server's response for OAuth 2.0 tokens using the "fetch_token" method of the flow object.
- Resulting credentials object is saved to the session in a dictionary form.
- Saved credentials are then loaded from the session and used to build a client library for the Google Calendar API.
- Fetches the calendar list for the user and retrieves the first calendar in the list
-
Enable the Calendar API in Cloud Console
The CalDAV API lets you manage your Google calendars and events.