Module googleapis.gcalendar

ballerinax/googleapis.gcalendar Ballerina library

4.0.0

Overview

The Ballerina Google Calendar Connector provides the capability to manage events and calendar operations. It also provides the capability to support service account authorization that can provide delegated domain-wide access to the GSuite domain and support admins to do operations on behalf of the domain users.

The Ballerina Google Calendar module supports Google Calendar API V3.

Set up Guide

To utilize the Calendar connector, you must have access to the Calendar REST API through a Google Cloud Platform (GCP) account and a project under it. If you do not have a GCP account, you can sign up for one here.

Step 1: Create a Google Cloud Platform Project

In order to use the Google Calendar connector, you need to first create the Calendar credentials for the connector to interact with Calendar.

  1. Open the Google Cloud Platform Console.

  2. Click on the project drop-down menu and either select an existing project or create a new one for which you want to add an API key.

    GCP Console

Step 2: Enable Calendar API

  1. Navigate to the Library and enable the Calendar API.

    Enable Calendar API

  1. Click on the OAuth consent screen tab in the Google Cloud Platform console.

    Consent Screen

  2. Provide a name for the consent application and save your changes.

Step 4: Create OAuth Client

  1. Navigate to the Credentials tab in your Google Cloud Platform console.

  2. Click Create credentials and from the dropdown menu, select OAuth client ID.

    Create Credentials

  3. You will be directed to the OAuth consent screen, in which you need to fill in the necessary information below.

    FieldValue
    Application typeWeb Application
    NameCalendarConnector
    Authorized redirect URIshttps://developers.google.com/oauthplayground
  4. After filling in these details, click Create.

  5. Make sure to save the provided Client ID and Client secret.

Step 5: Get the Access and Refresh Tokens

Note: It is recommended to use the OAuth 2.0 playground to obtain the tokens.

  1. Configure the OAuth playground with the OAuth client ID and client secret.

    OAuth Playground

  2. Authorize the Calendar APIs.

    Authorize APIs

  3. Exchange the authorization code for tokens.

    Exchange Tokens

Quickstart

This sample demonstrates a scenario of creating a secondary calendar and adding a new event to it using the Ballerina Google Calendar connector.

Step 1: Import the package

Import the ballerinax/googleapis.gcalendar package into your Ballerina project.

Copy
import ballerinax/googleapis.gcalendar;

Step 2: Instantiate a new connector

Create a gcalendar:ConnectionConfig with the obtained OAuth2.0 tokens and initialize the connector with it.

Copy
configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string refreshToken = ?;
configurable string refreshUrl = ?;

gcalendar:Client calendarClient = check new ({
   auth: {
      clientId,
      clientSecret,
      refreshToken,
      refreshUrl
   }
});

Step 3: Invoke the connector operation

You can now utilize the operations available within the connector.

Copy
public function main() returns error? {
    gcalendar:Client calendarClient = ...//

    // create a calendar
    gcalendar:Calendar calendar = check calendarClient->/calendars.post({
        summary: "Work Schedule"
    });

    // quick add new event
    string eventTitle = "Sample Event";
    gcalendar:Event event = check calendarClient->/calendars/[calendarId]/events/quickAdd.post(eventTitle);
}

Examples

The Google Calendar connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering use cases like creating calendar, scheduling meeting events, and adding reminders.

  1. Project Management With Calendar API This example shows how to use Google calendar APIs to efficiently manage work schedule of a person. It interacts with the API for various tasks related to scheduling and organizing work-related events and meetings.
  2. Work Schedule Management With Calendar API This example shows how to use Google calendar APIs to managing personal project schedule and collaborating with team members.

For comprehensive information about the connector's functionality, configuration, and usage in Ballerina programs, refer to the Google Calendar connector's reference guide in Ballerina Central.

Import

import ballerinax/googleapis.gcalendar;Copy

Metadata

Released date: about 2 months ago

Version: 4.0.0

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.8.4

GraalVM compatible: Yes


Pull count

Total: 

Current verison: 0


Weekly downloads


Source repository


Keywords

Productivity/Calendars
Cost/Free
Vendor/Google
Collaboration
Enterprise IT
Management

Contributors

Other versions

4.0.1

4.0.0