
Configuring Mule Google Calendar Connector
The Google Calendar API is a RESTful API that can be accessed through explicit HTTP calls or using the Google Client Libraries. The API exposes most of the features available in the Google Calendar Web interface.
Events List:
In the Google Calendar API, you can retrieve a list of events from a calendar using the "Events list" method. This method allows you to retrieve events based on specified parameters, such as the calendar ID, time range, and other optional parameters.
Events Insert:
The "Events insert" method allows you to add a new event to a calendar. To use this method, you'll typically provide the necessary details for the event, such as its summary (title), start and end times, location, description, and any other relevant information.
Events Delete:
The "Events delete" method allows you to delete a particular event from a specified calendar. You typically need to provide the calendar ID and the event ID to identify the event you want to delete.
Events Update:
The "Events update" method allows you to update the details of a particular event in a specified calendar. Similar to other methods, you need to provide the calendar ID and the event ID to identify the event you want to update. Additionally, you provide the new details for the event.
STEP1: Designing API specifications in Design Center
1. Login to your Anypoint platform account and click on “Start Designing.”
2. Click on create new and select New API Spec.
It will open a new window as below. Give a name to your API spec and click on create API specification. It will create a basic structure of API.
4. Write RAML as per your requirement.
5. Then click on publish button and select publish to exchange.
6. Go to Exchange, and you can see that a newly created API is published.
Before we dive into the Studio, let’s get the Google calendar API set up.
STEP 2: Setting up Google Calendar API
1. Go to https://console.cloud.google.com
2. Click on New project > Enter a project name > Create.
3. Again, select the created project.
4. Search for Google calendar API and click on the Enable button.
5. Click on OAuth consent screen on the left side, select External option and click on Create.
6. Fill out all the mandatory fields.
7. In Scopes, click on 'ADD' or 'Remove Scopes,' select the first three scopes, then search for Google calendar API, once all are selected, click on the ‘update’ button.
8. Add test users by clicking ‘Add users’ (you can add multiple mail IDs).
9. Click on Credentials on the left side.
10. Create credentials > OAuth client ID > select ‘web application’.
11. Add authorised redirect URIs and click on Create.
12. Save or download the Client ID and secret in JSON format.
STEP 3: configuring API in Anypoint studio
1. Open your anypoint studio and create a new mule project by selecting file>new>mule project.
2. a name to your project and click on ‘Download RAML from design center’.
3. Search for the API you created and select that, and click on add and finish.
4. You can see the new project is scaffolded as follows: Depending upon resource/method, a pair number of flows are created.
5. Next import the Google calendar connector from the exchange.
6. Go to global elements and create a Google Calendar connector configuration.
7. Provide Client Id and Client secret in Consumer Key and secret.
Events List Connector
Using the Events List component to Return events on the specified Calendar.
Drag an Events list component from the Mule Palette and configure it as shown below.
Now Run the project and go to chrome, then search for http://localhost:8081/authorize
Before choosing the account, go to end of the link and include
‘&access_type=offline’.
Doing this will retrieve the access token along with the refresh token.
Note: The refresh token will only work in localhost
Choose the Gmail account, and the token will be retrieved.
Go to Postman and enter the path of Events Insert flow that was created.
It will return all the events from the specified calendar.
Events Insert Connector
Using the Events insert component to schedule meetings in Google Calendar.
Drag an Events insert component from the Mule Palette and configure it as shown below.
Mapping the input fields.
Go to Postman and enter the path of Events Create flow that was created.
Once the event has been created successfully, an email notification is sent to attendees.
Events Update Connector
Using the Events Update component to Update meeting in Google Calendar.
Drag an Events Update component from the Mule Palette and configure it as shown below.
Go to Postman and enter the path of Events Update flow that was created.
Once the event has been updated successfully, an email notification is sent to attendees.
Events Delete Connector
Using the Events Delete component to Delete meeting in Google Calendar.
Drag an Events Delete component from the Mule Palette and configure it as shown below.
Go to Postman and enter the path of Events Delete flow that was created.
Once the event has been deleted successfully, an email notification is sent to attendees.