1.0.28 • Published 4 years ago

@melkorcba-osl/googleapis-common v1.0.28

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Google-api-common

npm version downloads

google-api-common is a wrapper around google-api-nodejs-client that provides simpler javaScript APIs for common functions in following libraries.

Getting started

Installation

Run this to install via NPM

npm i @melkorcba-osl/googleapis-common

This library provides both client side and server side Auth clients.

const grantImplicit = require("@melkorcba-osl/googleapis-common/grant-implicit");
const { getTokenRequestURL } = grantImplicit;
const URL = getTokenRequestURL({
      client_id:
        "<Client ID>",
      redirect_uri: "<Redirect URI>",
      scope: ['<list Auth scopes here>'],
      response_type: "token",
    });
window.location.href = URL
const grantImplicit = require("@melkorcba-osl/googleapis-common/grant-implicit");
const { extractTokenFromUrl } = grantImplicit;
const access_token = extractTokenFromUrl(window.location.href);

Auth Client is created using 0Auth2 Client from googleapis/oAuthClient. The client_id, client_secret, redirect_uris needed to set as environment variables before creating the oAuth2 Client.

const grantExplicit = require("@melkorcba-osl/googleapis-common/grant-explicit");
const { AUTH_SCOPES } = require("@melkorcba-osl/googleapis-common/auth-scopes");
// creating oAuth2 client
const { getAuth, EXECUTION_ENVIRONMENTS } = grantExplicit();
const authClient = getAuth({type:EXECUTION_ENVIRONMENTS.SERVER });
// generate Token request URL and PKCE Codes.
// Scope abbreviations "DRIVE.VED_ALL_FILES" V - View, E - Edit, D - Delete ALL_FILES in the Drive
const scopes = [AUTH_SCOPES.AUTH_SCOPES.DRIVE.VED_ALL_FILES] 
const {authUrl, codes} = getAuthData(authClient, scopes);

Contributions

Contributors are welcomed with open arms. Please mind the Documentation still under development. Feel free to report any issues and support for new APIs.

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago