Socket
Book a DemoInstallSign in
Socket

@jeanycyang/google-api-access-token

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jeanycyang/google-api-access-token

get google api access token via service-account json file

1.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Google API Access Token

npm version Build Status Coverage Status

Get Google API access token from Google Cloud service account file/object.

Features

  • zero dependency

Install

npm install --save @jeanycyang/google-api-access-token

Usage

const getAccessToken = require('@jeanycyang/google-api-access-token');

Function getAccessToken returns a promise.

you can provide json file path or directly use object.

from a json file

const accessToken = await getAccessToken('./config/gckey.json', 'https://www.googleapis.com/drive/v2/files');

or

getAccessToken('./config/gckey.json', 'https://www.googleapis.com/drive/v2/files')
  .then(accessToken => { ... });

from google cloud key object

const accessToken = await getAccessToken({
    "type": "service_account",
  "project_id": "gcp-project-1245",
  "private_key_id": "xxxxx",
  "private_key": "-----BEGIN PRIVATE KEY-----....",
  "client_email": "user-name@gcp-project-1245.iam.gserviceaccount.com",
  "client_id": "1234874585712327208344",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/user-name%40gcp-project-1245.iam.gserviceaccount.com"
}, 'https://www.googleapis.com/drive/v2/files');

or

getAccessToken({
  "type": "service_account",
  "project_id": "gcp-project-1245",
  "private_key_id": "xxxxx",
  "private_key": "-----BEGIN PRIVATE KEY-----....",
  "client_email": "user-name@gcp-project-1245.iam.gserviceaccount.com",
  "client_id": "1234874585712327208344",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/user-name%40gcp-project-1245.iam.gserviceaccount.com"
}, 'https://www.googleapis.com/drive/v2/files')
  .then(accessToken => { ... });

References

License

MIT

Keywords

gcp

FAQs

Package last updated on 29 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.