Installation
This library is published through NPM. Install Googleapis and dependencies with the following command
Complete API Support List Https://developers.google.com/apis-explorer
Use
Example 1: Get full address via Google short address
var Google = require (' Googleapis ');
var urlshortener = Google.urlshortener (' v1 ');
var params = {shorturl: ' Http://goo.gl/xKbRu3 '};
Get the long URL of a shortened URL
urlshortener.url.get (params, function (err, response) {
console.log (' Long u RL is ', Response.longurl;
});
Example 2: Login authorization
This sample integrates OAUTH2 authentication, which allows you to gain access to the user token and refresh the token to prevent the session from expiring.
var Google = require (' Googleapis ');
var plus = google.plus (' v1 ');
var oauth2client = new OAuth2 (client_id, Client_secret, redirect_url);
Retrieve tokens via token exchange explained above or set them:
oauth2client.setcredentials ({
access_token: ' A ccess TOKEN here ',
refresh_token: ' Refresh TOKEN here '
};
Plus.people.get ({userId: ' Me ', auth:oauth2client}, function (err, response) {
//Handle ERR and Response
});
An example of a complete login authorization. Https://github.com/google/google-api-nodejs-client/blob/master/examples/oauth2.js
Example 3: File Upload
var fs = require (' FS ');
var drive = google.drive ({version: ' V2 ', auth:oauth2client});
Drive.files.insert ({
resource: {
title: ' Testimage.png ',
mimetype: ' Image/png '
},
Media: {
mimetype: ' Image/png ',
body:fs.createReadStream (' awesome.png ')//read streams are awesome!
}
} , callback);
Question answer?
If you have any questions, ask the StackOverflow.
If a vulnerability is found, it can be submitted to GitHub Issue