Skip to content

nektarai/zoom-api-client

Repository files navigation

Zoom API Client

This node package aims to provide a dependency-free and 100% typed and tested Zoom Api Client. We use it in production at Nektar.ai.

The code is heavily inspired by GoogleApis package.

Installation

npm install @nektarai/zoom-api-client

Usage

For now, this package includes only those APIs which Nektar uses. You can easily extend the functionality in your project and even contribute directly over here!

ZoomClient

This is the core provider of all authentication and requests for Zoom. It is recommended to create only one ZoomClient instance for all Oauth (non-S2SO) purposes.

import {ZoomClient} from '@nektarai/zoom-api-client';

const zoomClient = new ZoomClient({
    clientId: process.env.ZOOM_CLIENT_ID,
    clientSecret: process.env.ZOOM_CLIENT_SECRET,
    redirectUri: process.env.ZOOM_REDIRECT_URI,
    verificationKey: process.env.ZOOM_VERIFICATION_KEY, // optional
});

ZoomOauth

To use the Zoom's Oauth functionality

import {ZoomS2SO} from '@nektarai/zoom-api-client';

const zoomOauth = new ZoomOauth(zoomClient);

expressRouter.get('/zoom/oauth', (req, res) => {
  const state = {userId: req.params.userId};
  res.redirect(zoomOauth.getAuthorizationUrl(state));
});

ZoomS2SO

To use Zoom's Server-to-server oauth functionality

import {ZoomClient, ZoomS2SO} from '@nektarai/zoom-api-client';

const zoomClient = new ZoomClient({
  // S2SO credentials
})
const zoomS2so = new ZoomS2SO(zoomClient);

ZoomApi

To use Zoom Api's after authentication

import {ZoomApi} from '@nektarai/zoom-api-client';

...

expressRouter.get('/zoom/oauth/callback', async (req, res) => {
  const {state, code} = req.query;
  const stateParsed = JSON.parse(state);
  const tokens =  await zoomOauth.requestTokens(code);
  const zoomApi = new ZoomApi({
    client: zoomClient, // oauth or s2so
    tokens,
  });
  const userInfo = zoomApi.me();
  const result = await db.read(`SELECT * from "zoomUsers" where id='${userInfo.id}'`);
  if (result.size) res.end('Auth successful!');
  else res.end('Auth failed!');
});

Contribution

(WIP)

  1. Clone the repo
  2. Install dependencies with npm install
  3. Add additional APIs in src/ and tests in test/
  4. Make sure tests pass and raise a PR
  5. Take feedback, make iterative changes, and wait for your changes to be published!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published