标签: google-api-nodejs-client

Google Calendar API NodeJS - 指定字段

Heyo,我在我的NodeJS项目中使用google-api-nodejs-client软件包,我正在尝试为日历事件构建查询.它工作正常,但我无法指定"字段"字段.

这将返回五个完整的日历事件:

client.calendar.events.list({
    calendarId: gcal_id,
    maxResults: 5
})
.withAuthClient(authClient)
.execute(function(err, calendar) {
    if (err)
        console.log(err);
    else
        console.log(calendar);
});
Run Code Online (Sandbox Code Playgroud)

但这没有任何回报:

client.calendar.events.list({
    calendarId: gcal_id,
    maxResults: 5,
    fields: {
        items: ["end","start","status","summary"]
    }
})
.withAuthClient(authClient)
.execute(function(err, calendar) {
    if (err)
        console.log(err);
    else
        console.log(calendar);
});
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

fields: {
    items: "end,start,status,summary"
}
Run Code Online (Sandbox Code Playgroud)

基于Google Calendar V3 API,我应该可以进行如下查询:https: //www.googleapis.com/calendar/v3/calendars/gcal_id.google.com/events?maxResults = 5&fields = item(end) %2Cstart%2Cstatus%2Csummary)&key = {YOUR_API_KEY}

我不确定如何指定URL的"fields = items(end%2Cstart%2Cstatus%2Csummary)"部分,但我已经在Google的API资源管理器中对其进行了测试,但它确实有效,所以我知道我在做某事JavaScript中有错误.

任何帮助将非常感激.现在我想我只是清理我从第一个代码片段得到的响应.

google-api-nodejs-client

1
推荐指数
1
解决办法
2233
查看次数

Node.js。忙查询中缺少timeMin参数。Google Calendar API

我正在尝试在Node.js中使用google-api-nodejs-client。我timeMinfreebusy查询中的参数格式有问题。根据docs,值应为ISO格式的timedate。我试过了,但出现错误。在该event.list方法中,ISO格式字符串可以正常工作。

查询freebusy代码:

function freeBusyStatus (auth, calendarId) {
    const startDate = new Date('20 February 2018 12:00').toISOString()
    const endDate = new Date('20 February 2018 13:00').toISOString()
    const check = {
        auth: auth,
        // timeMin: '2018-02-20T12:00:00+03:00', //not working with same format too
        timeMin: new Date('20 February 2018 12:00'),
        timeMax: endDate,
        items: [{id: calendarId}]
    }
    calendar.freebusy.query (check, function (err, response) {
        if (err) {
            console.log ('error: ' + err)
        } else {
            ..some code..
        } …
Run Code Online (Sandbox Code Playgroud)

javascript google-calendar-api google-api-nodejs-client

1
推荐指数
1
解决办法
475
查看次数

通过Google Gmail API创建包含ID的标签

我正在尝试使用Gmail API的节点库创建一个带有自定义ID的标签.API有一个用于设置自己的id的请求参数,但是当我尝试创建标签时,我得到错误:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalidArgument",
    "message": "Invalid request"
   }
  ],
  "code": 400,
  "message": "Invalid request"
 }
}
Run Code Online (Sandbox Code Playgroud)

当我不给id时,标签创建没有问题.但是出于我的目的,我需要设置标准标签ID.任何人都知道这里发生了什么,或者它只是api的错误/错误?您可以尝试为自己的帐户创建自己的标签,并在此处查看我正在讨论的更多信息:https://developers.google.com/apis-explorer/#p/gmail/v1/gmail.users.labels.create

创建标签的代码:

var service = Google.gmail({version : 'v1', auth : oauth2Client});
service.users.labels.create({
    userId : 'user address here',
    labelListVisibility   : 'labelShow',
    messageListVisibility : 'show',
    name : 'label name here',
    id   : 'label id here'
}, function (err) {
    if (err) {
        throw err;
    } else {
       callback();
    }
});
Run Code Online (Sandbox Code Playgroud)

谢谢!

gmail google-api google-api-nodejs-client gmail-api

0
推荐指数
1
解决办法
1731
查看次数

NodeJS:Google PEM 例程:PEM_read_bio:无起始行

我正在 nodejs 应用程序中使用 googleapis,并且我正在尝试通过 gmail 帐户与日历进行交互。当我在本地机器上测试它时,它运行良好,但在部署它时出现错误

5|index    | Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
5|index    |     at Sign.sign (crypto.js:331:26)
5|index    |     at Object.sign (/home/ec2-user/api/node_modules/jwa/index.js:55:45)
5|index    |     at Object.jwsSign [as sign] (/home/ec2-user/api/node_modules/jws/lib/sign-stream.js:23:24)
5|index    |     at GoogleToken.<anonymous> (/home/ec2-user/api/node_modules/gtoken/src/index.ts:251:13)
5|index    |     at step (/home/ec2-user/api/node_modules/gtoken/build/src/index.js:42:23)
5|index    |     at Object.next (/home/ec2-user/api/node_modules/gtoken/build/src/index.js:23:53)
5|index    |     at /home/ec2-user/api/node_modules/gtoken/build/src/index.js:17:71
5|index    |     at new Promise (<anonymous>)
Run Code Online (Sandbox Code Playgroud)

下面是我尝试使用它的控制器。

import { google } from 'googleapis'
import { Request, Response, NextFunction } from 'express';

export class HolidayController {
    fetchHolidays(req: Request, res: Response, next: NextFunction) …
Run Code Online (Sandbox Code Playgroud)

google-api node.js google-oauth google-api-nodejs-client

0
推荐指数
1
解决办法
2341
查看次数