google-api-nodejs-client

renaming files in Google Cloud Storage?

◇◆丶佛笑我妖孽 提交于 2019-12-10 21:05:49
问题 Can you rename files in Google Cloud Storage? I am letting users upload photos, but I want to give them the ability to edit the photo, at least by changing the name they uploaded it with. I am using Javascript through Node.js. Thanks! 回答1: This command: gsutil mv gs://my_bucket/olddir gs://my_bucket/newdir will do the job. If you have a large number of files you need to do a multi-processing move, so use this command: gsutil -m mv gs://my_bucket/olddir gs://my_bucket/newdir You can find this

With the npm package googleapis how do I get the user's email address after authenticating them?

怎甘沉沦 提交于 2019-12-10 14:15:17
问题 I'm using this npm library - https://www.npmjs.com/package/googleapis and I'm using the following Express routes as /user/ : /* Redirect to the google login page */ router.get('/login', function (req, res) { res.redirect(auth.generateUrl()); }); /* The callback from the google OAuth API call */ router.get('/callback', function (req, res) { auth.authenticate(req.query.code); res.send(); }); auth is this module: var oAuth2 = require('googleapis').auth.OAuth2; var oauth2Client = new oAuth2(

Google Analytics Server Side Authorization to get Page View Count analytics data and display it to random visitors on the front page

爷,独闯天下 提交于 2019-12-10 11:48:53
问题 How can I display visitor count to your web page without having to logging in or authenticating like Google Analytics? I'm trying to implement Google Analytics Server Side Authorization to get Page View Count analytics data and display it to random visitors on the front page I read their docs and found service account but the issue is that there is no full example of doing it written in JavaScript. I tried this implementation. However, there is no client_email in googleServiceAccountKey.

Accessing a public calendar using Google API without requiring a user to log in

谁说我不能喝 提交于 2019-12-10 01:50:04
问题 I'd like to access a public calendar using Google's REST API. Google's calendar API suggests I need an OAuth token to get access to calendars: https://developers.google.com/google-apps/calendar/auth However, I'm accessing a public calendar and am doing this from the server so can't/shouldn't have to ask the user to authenticate. I'm using the node.js api: googleapis .discover('calendar', 'v3').execute(function(err, client) { client.calendar.calendars.get({ calendarId: '***@group.calendar

Google Datastore Silently Failing in Production (node.js)

非 Y 不嫁゛ 提交于 2019-12-08 12:54:25
问题 As part of a larger web app, I'm using a combination of Google Datastore and Firebase. On my local machine, all requests go through seamlessly, however when I deploy my app to the GAE (using node.js - Flexible Environment) everything works except the calls to the datastore. The requests do not throw an error, directly or via promise and just never return, hanging the process. My current configuration is set up to use a Service Account key file containing my private key. Ive checked that it

Creating label with id via Google Gmail API

家住魔仙堡 提交于 2019-12-08 10:45:08
问题 I am trying to create a label with a custom id using the node library for the Gmail API. The API has a request parameter for setting your own id however when I try to create the label I get the error: { "error": { "errors": [ { "domain": "global", "reason": "invalidArgument", "message": "Invalid request" } ], "code": 400, "message": "Invalid request" } } The label is created with no problems when I don't give an id. However for my purposes I need to have a set standard label id. Anyone know

browserify Error : http.createServer is not a function

若如初见. 提交于 2019-12-08 07:26:55
问题 I tried to browserify this node js script : var phantom = require('phantom') phantom.create(function(ph) { ph.createPage(function(page) { page.open("editor.html", function(status) { console.log("opened diagram? ", status); page.evaluate(function() { return document.getElementById("GraphImage").src; }, function(result) { //console.log(result); ph.exit(); }); }); }); }); So I used this command: browserify myscript.js > bundle.js and when I run bundle.js from an html file I get this error: http

Inserting Google Analytics Content Experiments using the Node.JS Client Library

房东的猫 提交于 2019-12-07 08:40:50
问题 I'm trying to configure a content experiment using the Node.js Client Library, and have not been able to work out the syntax. Where do I put the body (an Experiment resource) as described here? https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtExperimentsGuide#insert This code, for listing existing experiments, works as expected: var listExperiments = function(){ googleapis .discover('analytics', 'v3') .execute(function(err, client) { var request = client .analytics

Refresh token of google api do not work properly in nodejs

拈花ヽ惹草 提交于 2019-12-06 04:58:29
问题 I am using google api nodejs , I try to get data from google Anaytics var google = require('googleapis'); var OAuth2Client = google.auth.OAuth2; var CLIENT_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; var CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxx'; //var REDIRECT_URL = 'http://yieldops.co/oauth2Callback'; var REDIRECT_URL = 'http://localhost:8000/oauth2Callback'; var oauth2Client = new OAuth2Client(CLIENT_ID, CLIENT_SECRET,REDIRECT_URL); var credentials={} credentials.expiry_date= "1463514280558",

oauth2Client.getToken missing refresh_token

自作多情 提交于 2019-12-06 03:57:30
问题 I have a small express server that has two routes. Then it writes the json tokens to a file (I know very insecure). For some reason there's no refresh_token . In the docs theres a comment that offline for access_type gets refresh_token , which is set and it's still not working access_type: 'offline', // 'online' (default) or 'offline' (gets refresh_token) Here's the express server, sorry if the promises throw anyone off. var Promise = require("bluebird") var express = require('express') var