Overview

This module provides a minimal wrapper around the Google APIs Client Library.

It does/and will only do two things:

  1. Provide a simple to administer authentication settings page
  2. Provide a number of services which can be used to obtain an authenticated client to the various supported Google services, like Google Calendar, Google Drive, etc.

Included Services

If you'd like to see your needed service here, read the next section and submit a patch.

  • Google Calender

Adding a Service

It's very simple to extend this for your needed service client.

First, implement a GoogleApiServiceProvider plugin. Here is an example of a service plugin.

Then, add it as a registered service in a services.yml file. Here is an example of a real service definition. And here is the structure of a hypothetical service:

# Provides an authenticated client for 'my@email.com's Google calendar.                                         
gapi.calendar.my_calender:
  parent: gapi.default_service_provider
  arguments: ['gapi_calendar', {'subject_id': 'my@email.com'}]
#               ^ this id must match the plugin id from your newly defined plugin.
#                                  ^ optional plugin configuration

You can do this in your own module, but a patch would be most welcome!

Finally, you can use your authenticated client wherever you need it, like so:

$client = \Drupal::service('gapi.calendar.my_calendar');
$events = $client->events->listEvents('primary');

Note: wherever possible, you should be injecting your service instead of using \Drupal::service(). This is just for the sake of example.

Requirements

Installing via composer will automatically download all required libraries

Notes

  • This module is meant to be used as a base by other modules providing deeper integration to various Google services.
  • This module only provides an authenticated client via a service that can be injected into your controllers/blocks/plugins/etc.
  • For a list of the various Google services which could be supported, see the separate google-api-php-client-services repository.
  • Because the maintainer is unable to maintain this for every possible Google service, the available services are defined by a minimal plugin based system. You can add your own services by implementing this plugin in your own module. However, you are encouraged to submit it as a patch to this module. Any patch in the issue queue that adds a new service will be accepted provided that it meets Drupal coding standards and does not do anything "extra".
Supporting organizations: 

Project information

  • caution Seeking new maintainer
    The current maintainers are looking for new people to take ownership.
  • Created by johnennew on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    There are currently no supported stable releases.

Releases