0.0.2 • Published 3 years ago

google-apis-authenticator v0.0.2

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
3 years ago

Google APIs Authenticator

Google APIs Authentication made simple, just export your service account via GOOGLE_APPLICATION_CREDENTIALS environment variable and it's done.

This package knows when you are working on local environment or if you are using any Google service like Cloud Run, Cloud Functions,... Using a custom service account in those service is very convenient, but user impersonation is hard to achieve via googleapis nodeJS library, this library aims to unlock that block.

Installation:

npm install google-apis-authenticator

Requirements:

Enable iAM API here.

Service Account needed roles:

- Service Account Token Creator

Example:

import { GoogleApisAuthenticator } from 'google-apis-authenticator'
import { google } from 'googleapis'

const scopes = []
const impersonationEmail = 'impersoname@me.com'

const googleApisAuthenticator = new GoogleApisAuthenticator(scopes, impersonationEmail)

const auth = googleApisAuthenticator.getCredentials()
auth.then(async (crendentials) => {
  const res = await google.gmail({ version: 'v1', auth: credentials }).users.messages.list()
  console.log(res)
})