Tag: google api nodejs client

Node.js @ google-cloud / logging-winston不能在GCE实例内工作

我正在使用npm @ google-cloud / logging-winston将应用程序日志事件发送到Google堆栈驱动程序日志接收器。 下面是我的代码片段,它在我的本地macbook中工作得很好。 当我尝试在GCE实例(谷歌云上的Ubuntu 16.10图像计算实例)中运行它时,它不会将日志事件发送到日志接收器,我无法在Google云日志logging仪表板上看到它。 任何帮助在这里赞赏 ///// code start here const winston = require('winston'); const Logger = winston.Logger; const Console = winston.transports.Console; const LoggingWinston = require('@google-cloud/logging-winston'); // Instantiates a Winston Stackdriver Logging client const loggingWinston = LoggingWinston({ projectId: 'myproject-id', keyFilename: 'mykey.json', level: 'info',// log at 'warn' and above , labels: { "env": […]

Google Shopping API node.js产品插件返回“INSERT请求必须指定产品”错误

我正尝试使用以下node.js代码将产品插入到Google Shopping API,但是我一直在收到错误消息: { [Error: [product] INSERT request must specify product] code: 400, errors: [ { domain: 'global', reason: 'required', message: '[product] INSERT request must specify product' } ] } 这里是我的JavaScript代码(我在这里使用节点客户端: https : //github.com/google/google-api-nodejs-client/ ): var google = require('googleapis'); var OAuth2 = google.auth.OAuth2; var oauth2Client = new OAuth2(*OAUTHDETAILS*); oauth2Client.setCredentials({ access_token: '*ACCESSTOKEN*', //refresh_token: 'REFRESH TOKEN HERE' […]

Google OAuth2 API刷新令牌

我正在使用google-auth-library-nodejs库集成到一些GMail帐户中,以获取电子邮件列表。 我的stream程很简单: 1)尝试使用此function授权客户端: function _authorise(mailBox, callback) { let auth = new googleAuth(); let clientId = eval(`process.env.GMAIL_API_CLIENT_ID_${mailBox.toUpperCase()}`); let clientSecret = eval(`process.env.GMAIL_API_CLIENT_SECRET_${mailBox.toUpperCase()}`); let redirectUri = eval(`process.env.GMAIL_API_REDIRECT_URI_${mailBox.toUpperCase()}`); let tokenFile = process.env.GMAIL_API_TOKEN_PATH + mailBox.toLowerCase()+ process.env.GMAIL_API_TOKEN_BASE_FILE_NAME; let oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUri); fs.readFile(tokenFile, ((err, token) => { if (err) { _getNewToken(mailBox,oauth2Client,callback); } else { oauth2Client.credentials = JSON.parse(token); callback(oauth2Client); } […]

Google网站pipe理员NodeJs API了解响应

我试图了解当我尝试使用Google Webmasters API运行查询时收到的响应。 我没有得到一个错误,因为console.log返回null ,但是我收到了Not Found res参数,这使得它似乎有什么closures与传递给查询方法的params对象。 当我看着网站pipe理员的github文件 ,似乎我正确的顺序通过正确的领域,但一定要closures。 任何人都可以提供一些关于如何进一步debugging的指导,或者我的对象键值对清楚地说明了什么地方。 这是我的控制台: This is the error: null This is the response: Not Found 这里是这个问题的代码: /** * Lists the search query results * * @param {google.auth.OAuth2} auth An authorized OAuth2 client. */ function keywordQuery(auth) { console.log("This is the auth token" + auth); var webmasters = google.webmasters('v3'); var […]