Upgrading Zoom API Module from 2.x to 3.x

Last updated on
19 September 2023

In June 2023, Zoom is deprecating JWT apps. The 2.x version of the Zoom API module supported JWT apps and the 3.x version will support the new Server-to-Server OAuth App Type.

Converting from 2.x to 3.x. 

With Zoom no longer supporting JWT, we had to rearchitect several parts of the Zoom API module.

  1. In your project, run composer require "drupal/zoomapi ^3.0"
  2. Run a database update to enable apitools module.
  3. Create a Zoom Server-to-Server Oauth App - The big difference is setting up scopes (or specific permissions) for the API endpoints your app will be using.
  4. Reconfigure your Zoom API module in Drupal. There are a few new options that are needed for the Server-to-Server Oauth App type. Zoom API Configuration Screenshot
  5. Adjust your code usage. There are some breaking changes, but adjusting code should be relatively easy. The 3.x version is leveraging another contrib module called APITools that offloads the client and configuration and handles the new Oauth requirements.

2.x to 3.x Client code examples

The main advantage to using the Zoom API client is that it automatically handles authentication for every API request.

The big changes from 2.x to 3.x are:

  1. Getting rid of the generic request in favor of specific get, post, patch and delete methods.
  2. The first parameter will be the Zoom endpoint without the slash at the beginning. Example: users
  3. Passing in Guzzle options as the second parameter.
// The service name remains exactly the same \Drupal::service('zoomapi.client');
// If you were statically calling or injecting, there are no changes.

$client = \Drupal::service('zoomapi.client');

// Get Example.

// The old request method in 2.x.
$client->request('GET', '/users');

// The new get method in 3.x.
$client->get('users');

// Notice that the / slash before the endpoint is removed as well.


// Post Example.
$webinar_id = $data['zoom_webinar_id'];
$registrant = [
  'email' => $data['email_address'],
  'first_name' => $data['name']['first'],
  'last_name' => $data['name']['last'],
  'org' => $data['organization_name'],
];

// The old request method in 2.x.
$client->request(
  'post', '/webinars/' . $webinar_id . '/registrants',
  [],
  $registrant
);


// See https://docs.guzzlephp.org/en/stable/request-options.html.
// Notice the addition of the json key that will automatically convert the array to json upon posting.
$options = [
  'json' => [
    'email' => $data['email_address'],
    'first_name' => $data['name']['first'],
    'last_name' => $data['name']['last'],
    'org' => $data['organization_name'],
  ],
];

// The new post method in 3.x.
$client->post("webinars/{$webinar_id}/registrants", $options);

Help improve this page

Page status: No known problems

You can: