@ganesshkumar/gapi
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

gapi

A thin Node wrapper for Google's client-side javascript V3 API with TypeScript declaration.

Example

npm install --save gapi-client

yarn add gapi-client

index.js:

import gapi from '@ganesshkumar/gapi';

gapi.load('client:auth2', () => {
  gapi.client.init({
    discoveryDocs: ["<discoveryDocs_corresponding_to_the_APIs_you_use>"],
    clientId: '<your_client_id>',
    scope: '<scope_you_want_to_add>'
  }).then(function () {
    // do stuff with loaded APIs
    gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
    updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
  });
});

const updateSigninStatus = (isSignedIn) => {
  if (isSignedIn) {
    console.log('User is signed in')
  } else {
    console.log('User is not signed in')
  }
}

// To trigger the sign in flow, you can call the following function from appropriate place.
gapi.auth2.getAuthInstance().signIn();

TypeScript

This repo has the basic support for TypeScript.

License

Apache-2.0

Readme

Keywords

Package Sidebar

Install

npm i @ganesshkumar/gapi

Weekly Downloads

0

Version

0.2.0

License

Apache-2.0

Unpacked Size

42.5 kB

Total Files

7

Last publish

Collaborators

  • ganesshkumar