Skip to content

guillenotfound/google-apis-authenticator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 = '[email protected]'

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)
})

About

Google APIs authentication made simple for local & serverless.

Resources

License

Stars

Watchers

Forks

Packages

No packages published