nylas / nylas-nodejs

A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
MIT License
166 stars 116 forks source link

Added support for /v3/connect/tokeninfo endpoint #536

Closed mrashed-dev closed 5 months ago

mrashed-dev commented 5 months ago

Description

This PR adds support for the /v3/connect/tokeninfo endpoint.

Usage

There are two methods that are part of the Auth resource that allow you to get information on a token; one for the ID token (idTokenInfo) and one for the access token (accessTokenInfo).

import Nylas, { TokenInfoResponse } from "nylas";

const nylas = new Nylas({
  apiKey: 'nylas-api-key',
});

// Get information on an ID token
nylas.auth.idTokenInfo('idToken').then((response) => {
  const idTokenInfo: TokenInfoResponse = response.data;
  // ...
});

// Get information on an access token
nylas.auth.accessTokenInfo('accessToken').then((response) => {
  const accessTokenInfo: TokenInfoResponse = response.data;
  // ...
});

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.