1.1.4 • Published 6 years ago

service-account-token-requestor v1.1.4

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

GCP Service Account Token Requestor

Requests an access token from the Google OAuth 2.0 Authorization Server. This probably isn't necessary if using Google Compute Engine or Google App Engine.

Example

First, acquire a Service Account json file. Then provide the path to getToken.

const tokenRequestor = require("service-account-token-requestor");
const path_to_service_account_file = "/home/user/private-keys/service-account.json";

//returns a promise if no callback is provided
tokenRequestor.getToken(path_to_service_account_file)
.then(useTheToken);

//callback
tokenRequestor.getToken(path_to_service_account_file, (token, error)=>{
  if (error) { return handleError(error); }
  useTheToken(token);
});

Test

Provide path to service account json file in SERVICE_ACCT_FILE environment variable.

SERVICE_ACCT_FILE="../private-keys/service-account.json" npm test
1.1.4

6 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago