1.0.28 • Published 2 years ago

@melkorcba-osl/googleapis-common v1.0.28

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

1.0.27

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago