
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
google-api-utility
Advanced tools
This is a auth api wrapper (we use gapitoken module) and add a request method for api call. It use service account for authenticate, and persistance the key in cache and file.
This is a auth api wrapper (we use gapitoken module) and add a request method for api call. It use service account for authenticate, and persistance the key in cache and file.
We still not implement the refresh token, will be implement next release.
npm install google-api-utility
Follow the doc: http://gappsnews.blogspot.tw/2013/10/connect-cloud-platform-bigquery-using.html
From admin console, create a service account, save the client_secrets.json and it's key ex: Translate p12 to pem
openssl pkcs12 -in privatekey.p12 -out privatekey.pem -nocerts
openssl rsa -in privatekey.pem -out key.pem
or
openssl pkcs12 -in privatekey.p12 -nodes -nocerts > key.pem
You need to initial with auth.init() to put the scope, client_secret, privatekey_pem, key_pem parameters. These are we describe before. And we must to specify the scope for our query api, too.
var auth = require('google-api-utility')
, request = auth.request
, util = require('util')
, project = 'your-project-id';
auth.init({
scope: 'https://www.googleapis.com/auth/bigquery https://www.googleapis.com/auth/cloud-platform',
client_secret: '/path-to-client_secret.json',
key_pem: '/path-to-key.pem'
});
var bqurl = 'https://www.googleapis.com/bigquery/v2/projects/%s/datasets';
request({
url: util.format(bqurl, project),
method: 'GET'
}, function(err, req, doc){
if(err) console.log(err);
console.log(doc);
});
About 2015Q1 end, google start to deprecate the client_secret file download. You can change the init method like this:
auth.init({
scope: 'https://www.googleapis.com/auth/bigquery https://www.googleapis.com/auth/cloud-platform',
client_email: 'your-client-email@developer.gserviceaccount.com',
key_pem: '/path-to-key.pem'
});
The client_email can be find in project credential page. (Page url like: https://console.developers.google.com/project/[YOUR-PROJECT-ID]/apiui/credential)
Because GCP currently have json secret file. We currently support to initial it using json file:
auth.init({
scope: 'https://www.googleapis.com/auth/devstorage.full_control https://www.googleapis.com/auth/devstorage.read_write https://www.googleapis.com/auth/cloud-platform',
json_file: '/path/to/your-file.json'
});
Use timeout parameter in init function, and will be set in request timeout.
auth.init({
...,
timeout: 1000
})
The module bellow are my implements use this lib.
FAQs
This is a auth api wrapper (we use gapitoken module) and add a request method for api call. It use service account for authenticate, and persistance the key in cache and file.
The npm package google-api-utility receives a total of 168 weekly downloads. As such, google-api-utility popularity was classified as not popular.
We found that google-api-utility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.