How to use the googleapis.discover function in googleapis

To help you get started, we’ve selected a few googleapis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dwyl / app / BACKUP / oauth2.js View on Github external
.plus.people.get({ userId: userId })
    .withAuthClient(authClient)
    .execute(callback);
}

function printUserProfile(err, profile) {
  if (err) {
    console.log('An error occurred');
  } else {
    console.log(profile.displayName, ':', profile.tagline);
    console.log(profile)
  }
}

// load google plus v1 API resources and methods
googleapis
  .discover('plus', 'v1')
  .execute(function(err, client) {

  var oauth2Client =
    new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);

  // retrieve an access token
  getAccessToken(oauth2Client, function() {
    // retrieve user profile
    getUserProfile(
      client, oauth2Client, 'me', printUserProfile);
  });

});
github dwyl / app / BACKUP / oauth3.js View on Github external
var OAuth2Client = googleapis.OAuth2Client;

// Client ID and client secret are available at
// https://code.google.com/apis/console
var CLIENT_ID = '998322373435.apps.googleusercontent.com';
var CLIENT_SECRET = 'U8QgUx2ygHzI-n5txUPMgcYV';
var REDIRECT_URL = 'http://localhost/oauth2callback';

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});


// load google plus v1 API resources and methods
googleapis
  .discover('plus', 'v1')
  .execute(function(err, client) {

  var oauth2Client =
    new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);

  console.dir(oauth2Client);

  // generate consent page url
  var url = oauth2Client.generateAuthUrl({
    access_type: 'offline',
    scope: 'https://www.googleapis.com/auth/plus.me'
  });

  console.log('Visit the url: ', url)
github emil10001 / glass-mirror-nodejs-auth-demo / app.js View on Github external
var gotToken = function () {
    googleapis
        .discover('mirror', 'v1')
        .execute(function (err, client) {
            if (!!err) {
                failure();
                return;
            }
            console.log('mirror client', client);
            listTimeline(client, failure, success);
            insertHello(client, failure, success);
            insertContact(client, failure, success);
            insertLocation(client, failure, success);
            getLocation(client, failure, success);
        });
};
github silexlabs / unifile / lib / services / gdrive.js View on Github external
function deleteFile (file, request, response, next, cbk) {
	oauth2Client.credentials = request.session.gdrive_token;
	googleapis
	.discover('drive', 'v2')
	.execute(function(err, client) {
		if (err){
			var errCode = null;
			if (err.code){
				errCode = err.code;
			}
	    	cbk ({success:false, code:errCode});
			return;
		}
		try{
			client
			.drive.files.delete({"fileId":file.id})
			.withAuthClient(oauth2Client)
			.execute(function (a, b, c) {
				console.warn("File deleted "+file.title);
github silexlabs / unifile / lib / services / gdrive.js View on Github external
function moveFile (src_file, dst_file_data, request, response, next, cbk) {

	oauth2Client.credentials = request.session.gdrive_token;
	googleapis
	.discover('drive', 'v2')
	.execute(function(err, client) {
		if (err){
			var errCode = null;
			if (err.code){
				errCode = err.code;
			}
	    	cbk ({success:false, code:errCode});
			return;
		}
		try{
			client
			.drive.files.update({'fileId': src_file.id, 'resource': dst_file_data})
			.withAuthClient(oauth2Client)
			.execute(function (a, file_data, c) {
				console.warn("File moved ");
github silexlabs / unifile / lib / services / gdrive.js View on Github external
function copyFile (src_file, dst_file_data, request, response, next, cbk) {

	oauth2Client.credentials = request.session.gdrive_token;
	googleapis
	.discover('drive', 'v2')
	.execute(function(err, client) {
		if (err){
			var errCode = null;
			if (err.code){
				errCode = err.code;
			}
	    	cbk ({success:false, code:errCode});
			return;
		}
		try{
			client
			.drive.files.copy({'fileId': src_file.id, 'resource': dst_file_data})
			.withAuthClient(oauth2Client)
			.execute(function (a, file_data, c) {
				console.warn("File copyed ");
github licoliu / pomy / site / plugins / markdown / plugins / googledrive / googledrive.js View on Github external
_loadDriveIfRequired: function(callback) {
    if (!client) {
      googleapis.discover('drive', 'v2').execute(function(err, c) {
        client = c;
        callback();
      });
    } else {
      callback();
    }
  },
  generateAuthUrl: function() {
github silexlabs / unifile / lib / services / gdrive.js View on Github external
function getFile (file, request, response, next, cbk) {
	oauth2Client.credentials = request.session.gdrive_token;
	googleapis
	.discover('drive', 'v2')
	.execute(function(err, client) {
		if (err){
			var errCode = null;
			if (err.code){
				errCode = err.code;
			}
	    	cbk ({success:false, code:errCode});
			return;
		}
		try{

			downloadFile(file, request.session.gdrive_token.access_token, function (data) {
				if(data){
					cbk({success:true}, data, file.mimeType);
				}
github silexlabs / unifile / lib / services / gdrive.js View on Github external
function listFiles (folder_id, request, response, next, cbk) {
	oauth2Client.credentials = request.session.gdrive_token;
	var search_params = {};
	if (folder_id)
		search_params.q = "'"+folder_id+"' in parents";
	else
		search_params.q = "'"+request.session.gdrive_account.rootFolderId+"' in parents";

	googleapis
	.discover('drive', 'v2')
	.execute(function(err, client) {
		if (err){
			var errCode = null;
			if (err.code){
				errCode = err.code;
			}
	    	cbk ({success:false, code:errCode});
			return;
		}

		client
		.drive.files.list(search_params)
		.withAuthClient(oauth2Client)
		.execute(function (err, result, c) {